vani-meeting-server 2.2.8 → 2.3.0

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.
@@ -110,6 +110,7 @@ export declare class EachSocketConnectionHandler extends BaseSFUWebsocket {
110
110
  private redisSubscribtionDetails;
111
111
  private isReconnectionFromUrl;
112
112
  private numberOfPongWaiting;
113
+ private lastPingTime;
113
114
  private pingPongTimeout;
114
115
  private destoryCallback?;
115
116
  private connectionProtocol;
@@ -107,6 +107,7 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
107
107
  redisSubscribtionDetails = [];
108
108
  isReconnectionFromUrl = false;
109
109
  numberOfPongWaiting = 0;
110
+ lastPingTime = 0;
110
111
  pingPongTimeout = undefined;
111
112
  destoryCallback;
112
113
  connectionProtocol = ServerHandler_1.ServerHandler.getInstance().serverStartRequest.connectionProtocol;
@@ -165,6 +166,9 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
165
166
  }
166
167
  async onNewMessage(msgData) {
167
168
  this.numberOfPongWaiting = 0;
169
+ if ((this.lastPingTime + (20 * 1000)) < new Date().getTime()) {
170
+ this.startPingPong();
171
+ }
168
172
  const paylod = JSON.parse(msgData);
169
173
  if (paylod.type === WebSocketBasicEvents.Config) {
170
174
  this.onConfig(paylod.data);
@@ -337,6 +341,9 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
337
341
  this.redisBroadcastMessageToTopic(this.selfParticipant.userId, this.preapreClientMessageBody(true, this.selfParticipant, this.preapreWebSocketMessageBody(WebSocketBasicEvents.OnServerParticipants, userMap)));
338
342
  }
339
343
  async startPingPong() {
344
+ if (this.pingPongTimeout) {
345
+ clearTimeout(this.pingPongTimeout);
346
+ }
340
347
  this.pingPongTimeout = undefined;
341
348
  if (this.isUserJoinedFromAnotherSocket === false && this.selfParticipant && this.selfParticipant.roomId && this.selfParticipant.userId) {
342
349
  if (this.numberOfPongWaiting > 10) {
@@ -350,6 +357,7 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
350
357
  const user = await RedisHandler_1.RedisHandler.getInstance().getParticipantByUserId(this.selfParticipant.roomId, this.selfParticipant.userId);
351
358
  if (this.pingPongTimeout === undefined && user) {
352
359
  this.redisBroadcastMessageToTopic(this.selfParticipant.userId, this.preapreClientMessageBody(true, this.selfParticipant, this.preapreWebSocketMessageBody(WebSocketBasicEvents.Ping, { userId: this.selfParticipant.userId })));
360
+ this.lastPingTime = new Date().getTime();
353
361
  this.numberOfPongWaiting = this.numberOfPongWaiting + 1;
354
362
  this.pingPongTimeout = setTimeout(this.startPingPong, 5000);
355
363
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-server",
3
- "version": "2.2.8",
3
+ "version": "2.3.0",
4
4
  "description": "Vani Meeting Server SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",