vani-meeting-client 0.1.9 → 0.2.3

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.
@@ -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>;
@@ -72,7 +75,6 @@ export declare class WebsocketHandler extends Base {
72
75
  isWebScoketConnected(): boolean;
73
76
  sendSocketMessage(type: WebSocketEvents, data: any): void;
74
77
  reconnectOnInternetFailur(): void;
75
- private checkIfSocketConnected;
76
78
  private onWebSocketClosed;
77
79
  private tryToReconectSocket;
78
80
  private onSocketConnected;
@@ -80,5 +82,6 @@ export declare class WebsocketHandler extends Base {
80
82
  private askIfSetupDone;
81
83
  private onMessage;
82
84
  private onSetupDone;
85
+ private checkIfPingIsRunning;
83
86
  private isVideoCallControllerMessageType;
84
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,7 +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) {
214
- _this.checkIfSocketConnected();
220
+ // this.checkIfSocketConnected();
215
221
  log.info("connected ----");
216
222
  _this.isWebSocketConnectionInProgress = false;
217
223
  _this.isSetUpDone = false;
@@ -260,6 +266,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
260
266
  };
261
267
  WebsocketHandler.prototype.reconnectOnInternetFailur = function () {
262
268
  var _a;
269
+ log.info("reconnectOnInternetFailur");
263
270
  if (this.wss) {
264
271
  (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(VaniEvent.OnReconecting, {});
265
272
  this.wss.close(3005);
@@ -268,18 +275,17 @@ var WebsocketHandler = /** @class */ (function (_super) {
268
275
  this.connect(true);
269
276
  }
270
277
  };
271
- WebsocketHandler.prototype.checkIfSocketConnected = function () {
272
- var _this = this;
273
- window.setTimeout(function () {
274
- if (_this.isWebScoketConnected()) {
275
- log.info("Connected");
276
- _this.checkIfSocketConnected();
277
- }
278
- else {
279
- log.info("Not Connected");
280
- }
281
- }, 1000);
282
- };
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
+ // }
283
289
  WebsocketHandler.prototype.onWebSocketClosed = function (event) {
284
290
  var _this = this;
285
291
  log.info("onWebSocketClosed");
@@ -343,6 +349,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
343
349
  };
344
350
  WebsocketHandler.prototype.onMessage = function (message) {
345
351
  var _a, _b, _c, _d, _e, _f, _g, _h;
352
+ this.lastPingTimeStamp = new Date().getTime();
346
353
  var messagejson = JSON.parse(message);
347
354
  if (messagejson.type && messagejson.data) {
348
355
  var type = messagejson.type;
@@ -410,6 +417,29 @@ var WebsocketHandler = /** @class */ (function (_super) {
410
417
  (_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.emitMessageToSource(VaniEvent.OnConnected, {});
411
418
  }
412
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, _b;
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
+ (_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.emitMessageToSource(VaniEvent.OnNotReachable, {});
436
+ }
437
+ else {
438
+ this.pingCheckTimeout = window.setTimeout(function () {
439
+ _this.checkIfPingIsRunning();
440
+ }, 5 * 1000);
441
+ }
442
+ }
413
443
  };
414
444
  WebsocketHandler.prototype.isVideoCallControllerMessageType = function (type) {
415
445
  if (Object.values(SFUMessageType).includes(type)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-client",
3
- "version": "0.1.9",
3
+ "version": "0.2.3",
4
4
  "description": "Vani Meeting Clinet SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",