@xtr-dev/rondevu-client 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +15 -0
- package/dist/client.js +18 -0
- package/dist/connection.d.ts +6 -0
- package/dist/connection.js +21 -3
- package/dist/rondevu.js +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -108,4 +108,19 @@ export declare class RondevuAPI {
|
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
110
|
health(): Promise<HealthResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* Ends a session by deleting the offer from the server
|
|
113
|
+
*
|
|
114
|
+
* @param code - The offer code
|
|
115
|
+
* @returns Success confirmation
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
|
120
|
+
* await api.leave('my-offer-code');
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
leave(code: string): Promise<{
|
|
124
|
+
success: boolean;
|
|
125
|
+
}>;
|
|
111
126
|
}
|
package/dist/client.js
CHANGED
|
@@ -150,4 +150,22 @@ export class RondevuAPI {
|
|
|
150
150
|
method: 'GET',
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Ends a session by deleting the offer from the server
|
|
155
|
+
*
|
|
156
|
+
* @param code - The offer code
|
|
157
|
+
* @returns Success confirmation
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
|
162
|
+
* await api.leave('my-offer-code');
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
async leave(code) {
|
|
166
|
+
return this.request('/leave', {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
body: JSON.stringify({ code }),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
153
171
|
}
|
package/dist/connection.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare class RondevuConnection extends EventEmitter {
|
|
|
18
18
|
private connectionTimer?;
|
|
19
19
|
private isPolling;
|
|
20
20
|
private isClosed;
|
|
21
|
+
private hasConnected;
|
|
21
22
|
private wrtc?;
|
|
22
23
|
private RTCIceCandidate;
|
|
23
24
|
constructor(params: RondevuConnectionParams, client: RondevuAPI);
|
|
@@ -69,6 +70,11 @@ export declare class RondevuConnection extends EventEmitter {
|
|
|
69
70
|
* Clear connection timeout
|
|
70
71
|
*/
|
|
71
72
|
private clearConnectionTimeout;
|
|
73
|
+
/**
|
|
74
|
+
* Leave the session by deleting the offer on the server and closing the connection
|
|
75
|
+
* This ends the session for all connected peers
|
|
76
|
+
*/
|
|
77
|
+
leave(): Promise<void>;
|
|
72
78
|
/**
|
|
73
79
|
* Close the connection and cleanup resources
|
|
74
80
|
*/
|
package/dist/connection.js
CHANGED
|
@@ -7,6 +7,7 @@ export class RondevuConnection extends EventEmitter {
|
|
|
7
7
|
super();
|
|
8
8
|
this.isPolling = false;
|
|
9
9
|
this.isClosed = false;
|
|
10
|
+
this.hasConnected = false;
|
|
10
11
|
this.id = params.id;
|
|
11
12
|
this.role = params.role;
|
|
12
13
|
this.pc = params.pc;
|
|
@@ -66,9 +67,12 @@ export class RondevuConnection extends EventEmitter {
|
|
|
66
67
|
const state = this.pc.connectionState;
|
|
67
68
|
switch (state) {
|
|
68
69
|
case 'connected':
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (!this.hasConnected) {
|
|
71
|
+
this.hasConnected = true;
|
|
72
|
+
this.clearConnectionTimeout();
|
|
73
|
+
this.stopPolling();
|
|
74
|
+
this.emit('connect');
|
|
75
|
+
}
|
|
72
76
|
break;
|
|
73
77
|
case 'disconnected':
|
|
74
78
|
this.emit('disconnect');
|
|
@@ -236,6 +240,20 @@ export class RondevuConnection extends EventEmitter {
|
|
|
236
240
|
this.connectionTimer = undefined;
|
|
237
241
|
}
|
|
238
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Leave the session by deleting the offer on the server and closing the connection
|
|
245
|
+
* This ends the session for all connected peers
|
|
246
|
+
*/
|
|
247
|
+
async leave() {
|
|
248
|
+
try {
|
|
249
|
+
await this.client.leave(this.id);
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
// Ignore errors - session might already be expired
|
|
253
|
+
console.debug('Leave error (ignored):', err);
|
|
254
|
+
}
|
|
255
|
+
this.close();
|
|
256
|
+
}
|
|
239
257
|
/**
|
|
240
258
|
* Close the connection and cleanup resources
|
|
241
259
|
*/
|
package/dist/rondevu.js
CHANGED
|
@@ -40,7 +40,7 @@ export class Rondevu {
|
|
|
40
40
|
async checkServerVersion() {
|
|
41
41
|
try {
|
|
42
42
|
const { version: serverVersion } = await this.api.health();
|
|
43
|
-
const clientVersion = '0.3.
|
|
43
|
+
const clientVersion = '0.3.5'; // Should match package.json
|
|
44
44
|
if (!this.isVersionCompatible(clientVersion, serverVersion)) {
|
|
45
45
|
console.warn(`[Rondevu] Version mismatch: client v${clientVersion}, server v${serverVersion}. ` +
|
|
46
46
|
'This may cause compatibility issues.');
|