vani-meeting-client 2.1.9 → 2.2.1-beta0
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/lib/MeetingHandler.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ export declare class MeetingHandler {
|
|
|
14
14
|
private userMediaHandler?;
|
|
15
15
|
meetingStartRequestObject(roomId: string, userId: string, appId: string, wssUrl: string, shouldIgnoreCaseForRoomId?: boolean): MeetingStartRequest;
|
|
16
16
|
endAndDestory(): void;
|
|
17
|
+
cleanupWebsocket: () => void;
|
|
17
18
|
requestToCloseTheRoom: () => void;
|
|
19
|
+
preconnect: (url: string) => Promise<void>;
|
|
18
20
|
init(): Promise<boolean>;
|
|
19
21
|
recreateVideoCallHandler: () => Promise<BaseVideoCallHandler>;
|
|
20
22
|
switchCamera(): void;
|
package/lib/MeetingHandler.js
CHANGED
|
@@ -46,10 +46,28 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
46
46
|
function MeetingHandler() {
|
|
47
47
|
var _this = this;
|
|
48
48
|
this.communicationHandler = new CommunicationHandler(this);
|
|
49
|
+
this.cleanupWebsocket = function () {
|
|
50
|
+
var _a;
|
|
51
|
+
try {
|
|
52
|
+
(_a = _this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
53
|
+
_this.websocketCallHandler = undefined;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
}
|
|
57
|
+
};
|
|
49
58
|
this.requestToCloseTheRoom = function () {
|
|
50
59
|
var _a;
|
|
51
60
|
(_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.requestToCloseTheRoom();
|
|
52
61
|
};
|
|
62
|
+
this.preconnect = function (url) { return __awaiter(_this, void 0, void 0, function () {
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
if (!this.websocketCallHandler) {
|
|
65
|
+
this.websocketCallHandler = new WebsocketHandler(this.meetingStartRequest, this.communicationHandler);
|
|
66
|
+
}
|
|
67
|
+
this.websocketCallHandler.startSocketConnection(true, url);
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
});
|
|
70
|
+
}); };
|
|
53
71
|
this.recreateVideoCallHandler = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
54
72
|
var _a;
|
|
55
73
|
var _b;
|
|
@@ -80,6 +80,7 @@ export interface WebSocketMessageBody {
|
|
|
80
80
|
data?: any;
|
|
81
81
|
}
|
|
82
82
|
export declare class WebsocketHandler extends Base {
|
|
83
|
+
private websocketConnectionUrl?;
|
|
83
84
|
private loadBalancerIpAddressForWebSocket?;
|
|
84
85
|
private isEnded;
|
|
85
86
|
private isWebSocketConnectionInProgress;
|
|
@@ -93,8 +94,9 @@ export declare class WebsocketHandler extends Base {
|
|
|
93
94
|
private lastPingTimeStamp;
|
|
94
95
|
protected onObjectCreated(): void;
|
|
95
96
|
cleanup(): Promise<void>;
|
|
96
|
-
startSocketConnection(): Promise<void>;
|
|
97
|
+
startSocketConnection(isForPreConnect?: boolean, url?: string): Promise<void>;
|
|
97
98
|
private connect;
|
|
99
|
+
isWebScoketConnectedWithoutSetup(): boolean;
|
|
98
100
|
isWebScoketConnected(): boolean;
|
|
99
101
|
sendSocketMessage(type: WebSocketEvents, data: any): void;
|
|
100
102
|
reconnectOnInternetFailur(): void;
|
|
@@ -197,16 +197,16 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
197
197
|
});
|
|
198
198
|
});
|
|
199
199
|
};
|
|
200
|
-
WebsocketHandler.prototype.startSocketConnection = function () {
|
|
200
|
+
WebsocketHandler.prototype.startSocketConnection = function (isForPreConnect, url) {
|
|
201
201
|
return __awaiter(this, void 0, void 0, function () {
|
|
202
202
|
var request, urlToGetIpAddress, config;
|
|
203
203
|
var _this = this;
|
|
204
204
|
return __generator(this, function (_a) {
|
|
205
|
-
if (!this.meetingStartRequest) {
|
|
205
|
+
if (!this.meetingStartRequest && !isForPreConnect) {
|
|
206
206
|
log.log("meetingStartRequest not found on startSocketConnection");
|
|
207
207
|
return [2 /*return*/];
|
|
208
208
|
}
|
|
209
|
-
if (this.meetingStartRequest.dynamicWebSocketFetchBaseUrl) {
|
|
209
|
+
if (!isForPreConnect && this.meetingStartRequest.dynamicWebSocketFetchBaseUrl) {
|
|
210
210
|
if (this.meetingStartRequest.dynamicWebSocketFetchBaseUrl.endsWith("/") === false) {
|
|
211
211
|
this.meetingStartRequest.dynamicWebSocketFetchBaseUrl = this.meetingStartRequest.dynamicWebSocketFetchBaseUrl + "/";
|
|
212
212
|
}
|
|
@@ -234,46 +234,60 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
236
|
else {
|
|
237
|
-
this.connect(false);
|
|
237
|
+
this.connect(false, isForPreConnect, url);
|
|
238
238
|
}
|
|
239
239
|
return [2 /*return*/];
|
|
240
240
|
});
|
|
241
241
|
});
|
|
242
242
|
};
|
|
243
|
-
WebsocketHandler.prototype.connect = function (isForceFully) {
|
|
243
|
+
WebsocketHandler.prototype.connect = function (isForceFully, isForPreConnect, _url) {
|
|
244
244
|
var _a, _b, _c;
|
|
245
245
|
if (isForceFully === void 0) { isForceFully = false; }
|
|
246
246
|
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
-
var
|
|
247
|
+
var url_1;
|
|
248
248
|
var _this = this;
|
|
249
249
|
return __generator(this, function (_d) {
|
|
250
250
|
if (this.isEnded === true || this.isWebSocketConnectionInProgress) {
|
|
251
251
|
return [2 /*return*/];
|
|
252
252
|
}
|
|
253
|
-
if (!this.wss || (isForceFully && this.
|
|
254
|
-
|
|
255
|
-
if (this.loadBalancerIpAddressForWebSocket) {
|
|
256
|
-
|
|
253
|
+
if (!this.wss || (isForceFully && this.isWebScoketConnectedWithoutSetup() === false)) {
|
|
254
|
+
url_1 = _url;
|
|
255
|
+
// if (this.loadBalancerIpAddressForWebSocket) {
|
|
256
|
+
// url = "ws://" + this.loadBalancerIpAddressForWebSocket + ":4003/?connection=";
|
|
257
|
+
// }
|
|
258
|
+
// else
|
|
259
|
+
if (!url_1 && ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.wssUrl) && this.meetingStartRequest.wssUrl !== null) {
|
|
260
|
+
url_1 = this.meetingStartRequest.wssUrl;
|
|
257
261
|
}
|
|
258
|
-
|
|
259
|
-
|
|
262
|
+
if (url_1 !== this.websocketConnectionUrl) {
|
|
263
|
+
if (this.wss) {
|
|
264
|
+
this.wss.close();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (!url_1.includes("connection=")) {
|
|
268
|
+
url_1 = url_1 + "/?connection=";
|
|
260
269
|
}
|
|
261
|
-
|
|
262
|
-
|
|
270
|
+
debugger;
|
|
271
|
+
if (url_1) {
|
|
272
|
+
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("Connecting to ", url_1);
|
|
263
273
|
this.isWebSocketConnectionInProgress = true;
|
|
264
274
|
if (this.meetingStartRequest && ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.isMobileApp)) {
|
|
265
|
-
this.wss = new WebSocket(
|
|
275
|
+
this.wss = new WebSocket(url_1 + this.connection);
|
|
266
276
|
}
|
|
267
277
|
else {
|
|
268
|
-
this.wss = new WebSocket(
|
|
278
|
+
this.wss = new WebSocket(url_1 + this.connection);
|
|
269
279
|
}
|
|
270
280
|
this.wss.onopen = function (event) {
|
|
281
|
+
debugger;
|
|
271
282
|
// this.checkIfSocketConnected();
|
|
272
283
|
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("connected ----");
|
|
273
284
|
_this.isWebSocketConnectionInProgress = false;
|
|
274
285
|
_this.isSetUpDone = false;
|
|
286
|
+
_this.websocketConnectionUrl = url_1;
|
|
275
287
|
_this.socketCheckTimeout = undefined;
|
|
276
|
-
|
|
288
|
+
if (!isForPreConnect) {
|
|
289
|
+
_this.onSocketConnected();
|
|
290
|
+
}
|
|
277
291
|
};
|
|
278
292
|
this.wss.onmessage = function (event) {
|
|
279
293
|
_this.isWebSocketConnectionInProgress = false;
|
|
@@ -294,6 +308,8 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
294
308
|
}
|
|
295
309
|
};
|
|
296
310
|
this.wss.onclose = function (event) {
|
|
311
|
+
debugger;
|
|
312
|
+
_this.isSetUpDone = false;
|
|
297
313
|
_this.isWebSocketConnectionInProgress = false;
|
|
298
314
|
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && ("WebSocket is closed now.");
|
|
299
315
|
// log.warn(event)
|
|
@@ -301,14 +317,17 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
301
317
|
};
|
|
302
318
|
}
|
|
303
319
|
}
|
|
304
|
-
else if (isForceFully === false && this.isWebScoketConnected()) {
|
|
320
|
+
else if (isForceFully === false && !isForPreConnect && this.isWebScoketConnected()) {
|
|
305
321
|
(_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.emitMessageToSource(VaniEvent.OnSocketConnected, {});
|
|
306
322
|
}
|
|
323
|
+
else if (isForPreConnect && this.isWebScoketConnectedWithoutSetup() && !this.isSetUpDone) {
|
|
324
|
+
this.onSocketConnected();
|
|
325
|
+
}
|
|
307
326
|
return [2 /*return*/];
|
|
308
327
|
});
|
|
309
328
|
});
|
|
310
329
|
};
|
|
311
|
-
WebsocketHandler.prototype.
|
|
330
|
+
WebsocketHandler.prototype.isWebScoketConnectedWithoutSetup = function () {
|
|
312
331
|
var _a;
|
|
313
332
|
if (this.wss && this.wss.readyState === 1) {
|
|
314
333
|
return true;
|
|
@@ -316,6 +335,14 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
316
335
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("this.wss.readyState", this.wss, (_a = this.wss) === null || _a === void 0 ? void 0 : _a.readyState);
|
|
317
336
|
return false;
|
|
318
337
|
};
|
|
338
|
+
WebsocketHandler.prototype.isWebScoketConnected = function () {
|
|
339
|
+
var _a;
|
|
340
|
+
if (this.wss && this.wss.readyState === 1 && this.isSetUpDone) {
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("this.wss.readyState", this.wss, (_a = this.wss) === null || _a === void 0 ? void 0 : _a.readyState);
|
|
344
|
+
return false;
|
|
345
|
+
};
|
|
319
346
|
WebsocketHandler.prototype.sendSocketMessage = function (type, data) {
|
|
320
347
|
var _a;
|
|
321
348
|
if (this.isWebScoketConnected()) {
|