vani-meeting-client 0.1.8 → 0.2.2
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/inter-communication-handler/CommunicationHandler.js +0 -1
- package/lib/video-call-handler/SFUHandler.d.ts +1 -0
- package/lib/video-call-handler/SFUHandler.js +13 -0
- package/lib/websocket-handler/WebsocketHandler.d.ts +5 -1
- package/lib/websocket-handler/WebsocketHandler.js +42 -0
- package/package.json +1 -1
|
@@ -350,7 +350,6 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
350
350
|
this.internetReachbilityTimeout = undefined;
|
|
351
351
|
if (count < 2 && ((_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.isWebScoketConnected())) {
|
|
352
352
|
(_b = this.videoCallHandler) === null || _b === void 0 ? void 0 : _b.reconnectedWithoutPing();
|
|
353
|
-
return;
|
|
354
353
|
}
|
|
355
354
|
(_c = this.websocketCallHandler) === null || _c === void 0 ? void 0 : _c.reconnectOnInternetFailur();
|
|
356
355
|
}
|
|
@@ -20,6 +20,7 @@ export declare class SFUHandler extends BaseVideoCallHandler {
|
|
|
20
20
|
sendTrack(track: Track): Promise<void>;
|
|
21
21
|
onParticipantUpdated(): void;
|
|
22
22
|
init(): Promise<void>;
|
|
23
|
+
private onTransportNotFound;
|
|
23
24
|
private addObserverForDevice;
|
|
24
25
|
private onRouterRtpCapabilities;
|
|
25
26
|
private onTransportConnectDone;
|
|
@@ -228,6 +228,16 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
228
228
|
});
|
|
229
229
|
});
|
|
230
230
|
};
|
|
231
|
+
SFUHandler.prototype.onTransportNotFound = function (data) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
233
|
+
var messageJson;
|
|
234
|
+
return __generator(this, function (_a) {
|
|
235
|
+
messageJson = { to: "self", type: SFUMessageType.OnCreateTransports, message: SFUMessageType.OnCreateTransports };
|
|
236
|
+
this.sendSFUMessageToSocket(messageJson);
|
|
237
|
+
return [2 /*return*/];
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
};
|
|
231
241
|
SFUHandler.prototype.addObserverForDevice = function () {
|
|
232
242
|
return __awaiter(this, void 0, void 0, function () {
|
|
233
243
|
var _this = this;
|
|
@@ -368,6 +378,9 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
368
378
|
else if (websocketCallHandler.type === SFUMessageType.OnTrackEnded) {
|
|
369
379
|
this.onTrackEnded(websocketCallHandler.data);
|
|
370
380
|
}
|
|
381
|
+
else if (websocketCallHandler.type === SFUMessageType.OnTransportNotFound) {
|
|
382
|
+
this.onTransportNotFound(websocketCallHandler.data);
|
|
383
|
+
}
|
|
371
384
|
};
|
|
372
385
|
SFUHandler.prototype.onTrackEnded = function (data) {
|
|
373
386
|
var _a, _b;
|
|
@@ -49,7 +49,8 @@ export declare enum SFUMessageType {
|
|
|
49
49
|
OnSpeakerChanged = "onSpeakerChanged",
|
|
50
50
|
OnRestartIceCandidate = "restartIceCandidate",
|
|
51
51
|
OnTrackEnded = "onTrackEnded",
|
|
52
|
-
UpdateSpatialConsumer = "updateSpatialConsumer"
|
|
52
|
+
UpdateSpatialConsumer = "updateSpatialConsumer",
|
|
53
|
+
OnTransportNotFound = "onTransportNotFound"
|
|
53
54
|
}
|
|
54
55
|
export declare type WebSocketEvents = SFUMessageType | WebSocketBasicEvents;
|
|
55
56
|
export interface WebSocketMessageBody {
|
|
@@ -64,7 +65,9 @@ export declare class WebsocketHandler extends Base {
|
|
|
64
65
|
private connection;
|
|
65
66
|
private isSetUpDone;
|
|
66
67
|
private socketCheckTimeout?;
|
|
68
|
+
private pingCheckTimeout?;
|
|
67
69
|
private setUpTry;
|
|
70
|
+
private lastPingTimeStamp;
|
|
68
71
|
protected onObjectCreated(): void;
|
|
69
72
|
cleanup(): void;
|
|
70
73
|
startSocketConnection(): Promise<void>;
|
|
@@ -79,5 +82,6 @@ export declare class WebsocketHandler extends Base {
|
|
|
79
82
|
private askIfSetupDone;
|
|
80
83
|
private onMessage;
|
|
81
84
|
private onSetupDone;
|
|
85
|
+
private checkIfPingIsRunning;
|
|
82
86
|
private isVideoCallControllerMessageType;
|
|
83
87
|
}
|
|
@@ -106,6 +106,7 @@ export var SFUMessageType;
|
|
|
106
106
|
SFUMessageType["OnRestartIceCandidate"] = "restartIceCandidate";
|
|
107
107
|
SFUMessageType["OnTrackEnded"] = "onTrackEnded";
|
|
108
108
|
SFUMessageType["UpdateSpatialConsumer"] = "updateSpatialConsumer";
|
|
109
|
+
SFUMessageType["OnTransportNotFound"] = "onTransportNotFound";
|
|
109
110
|
})(SFUMessageType || (SFUMessageType = {}));
|
|
110
111
|
var ConnectionType;
|
|
111
112
|
(function (ConnectionType) {
|
|
@@ -121,6 +122,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
121
122
|
_this.connection = ConnectionType.new;
|
|
122
123
|
_this.isSetUpDone = false;
|
|
123
124
|
_this.setUpTry = 0;
|
|
125
|
+
_this.lastPingTimeStamp = 0;
|
|
124
126
|
return _this;
|
|
125
127
|
}
|
|
126
128
|
WebsocketHandler.prototype.onObjectCreated = function () {
|
|
@@ -139,6 +141,10 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
139
141
|
window.clearTimeout(this.socketCheckTimeout);
|
|
140
142
|
this.socketCheckTimeout = undefined;
|
|
141
143
|
}
|
|
144
|
+
if (this.pingCheckTimeout) {
|
|
145
|
+
window.clearTimeout(this.pingCheckTimeout);
|
|
146
|
+
this.pingCheckTimeout = undefined;
|
|
147
|
+
}
|
|
142
148
|
};
|
|
143
149
|
WebsocketHandler.prototype.startSocketConnection = function () {
|
|
144
150
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -211,6 +217,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
211
217
|
this.wss = new WebSocket(url + this.connection);
|
|
212
218
|
}
|
|
213
219
|
this.wss.onopen = function (event) {
|
|
220
|
+
// this.checkIfSocketConnected();
|
|
214
221
|
log.info("connected ----");
|
|
215
222
|
_this.isWebSocketConnectionInProgress = false;
|
|
216
223
|
_this.isSetUpDone = false;
|
|
@@ -259,6 +266,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
259
266
|
};
|
|
260
267
|
WebsocketHandler.prototype.reconnectOnInternetFailur = function () {
|
|
261
268
|
var _a;
|
|
269
|
+
log.info("reconnectOnInternetFailur");
|
|
262
270
|
if (this.wss) {
|
|
263
271
|
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(VaniEvent.OnReconecting, {});
|
|
264
272
|
this.wss.close(3005);
|
|
@@ -267,6 +275,17 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
267
275
|
this.connect(true);
|
|
268
276
|
}
|
|
269
277
|
};
|
|
278
|
+
// private checkIfSocketConnected() {
|
|
279
|
+
// window.setTimeout(() => {
|
|
280
|
+
// if (this.isWebScoketConnected()) {
|
|
281
|
+
// log.info("Connected")
|
|
282
|
+
// this.checkIfSocketConnected();
|
|
283
|
+
// }
|
|
284
|
+
// else {
|
|
285
|
+
// log.info("Not Connected")
|
|
286
|
+
// }
|
|
287
|
+
// }, 1000);
|
|
288
|
+
// }
|
|
270
289
|
WebsocketHandler.prototype.onWebSocketClosed = function (event) {
|
|
271
290
|
var _this = this;
|
|
272
291
|
log.info("onWebSocketClosed");
|
|
@@ -330,6 +349,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
330
349
|
};
|
|
331
350
|
WebsocketHandler.prototype.onMessage = function (message) {
|
|
332
351
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
352
|
+
this.lastPingTimeStamp = new Date().getTime();
|
|
333
353
|
var messagejson = JSON.parse(message);
|
|
334
354
|
if (messagejson.type && messagejson.data) {
|
|
335
355
|
var type = messagejson.type;
|
|
@@ -397,6 +417,28 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
397
417
|
(_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.emitMessageToSource(VaniEvent.OnConnected, {});
|
|
398
418
|
}
|
|
399
419
|
}
|
|
420
|
+
if (this.pingCheckTimeout) {
|
|
421
|
+
window.clearTimeout(this.pingCheckTimeout);
|
|
422
|
+
this.pingCheckTimeout = undefined;
|
|
423
|
+
}
|
|
424
|
+
this.checkIfPingIsRunning();
|
|
425
|
+
};
|
|
426
|
+
WebsocketHandler.prototype.checkIfPingIsRunning = function () {
|
|
427
|
+
var _this = this;
|
|
428
|
+
var _a;
|
|
429
|
+
console.log("checkIfPingIsRunning");
|
|
430
|
+
if (this.isWebScoketConnected()) {
|
|
431
|
+
if ((this.lastPingTimeStamp + (40 * 1000)) < new Date().getTime()) {
|
|
432
|
+
this.pingCheckTimeout = undefined;
|
|
433
|
+
//Discounted
|
|
434
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.onIceCandidateDisconnected();
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
this.pingCheckTimeout = window.setTimeout(function () {
|
|
438
|
+
_this.checkIfPingIsRunning();
|
|
439
|
+
}, 5 * 1000);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
400
442
|
};
|
|
401
443
|
WebsocketHandler.prototype.isVideoCallControllerMessageType = function (type) {
|
|
402
444
|
if (Object.values(SFUMessageType).includes(type)) {
|