vani-meeting-server 1.6.0 → 1.6.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.
@@ -95,6 +95,7 @@ export declare class EachSocketConnectionHandler extends BaseSFUWebsocket {
95
95
  private redisSubscribtionDetails;
96
96
  private isReconnectionFromUrl;
97
97
  private numberOfPongWaiting;
98
+ private pingPongTimeout;
98
99
  private destoryCallback?;
99
100
  private connectionProtocol;
100
101
  constructor(socket: WebSocket.WebSocket, isReconnectionFromUrl: boolean);
@@ -93,6 +93,7 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
93
93
  redisSubscribtionDetails = [];
94
94
  isReconnectionFromUrl = false;
95
95
  numberOfPongWaiting = 0;
96
+ pingPongTimeout = undefined;
96
97
  destoryCallback;
97
98
  connectionProtocol = ServerHandler_1.ServerHandler.getInstance().serverStartRequest.connectionProtocol;
98
99
  constructor(socket, isReconnectionFromUrl) {
@@ -149,6 +150,7 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
149
150
  this.cleanUp();
150
151
  }
151
152
  async onNewMessage(msgData) {
153
+ this.numberOfPongWaiting = 0;
152
154
  const paylod = JSON.parse(msgData);
153
155
  if (paylod.type === WebSocketBasicEvents.Config) {
154
156
  this.onConfig(paylod.data);
@@ -320,9 +322,10 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
320
322
  });
321
323
  this.redisBroadcastMessageToTopic(this.selfParticipant.userId, this.preapreClientMessageBody(true, this.selfParticipant, this.preapreWebSocketMessageBody(WebSocketBasicEvents.OnServerParticipants, userMap)));
322
324
  }
323
- startPingPong() {
324
- if (this.isUserJoinedFromAnotherSocket === false && this.selfParticipant) {
325
- if (this.numberOfPongWaiting > 8) {
325
+ async startPingPong() {
326
+ this.pingPongTimeout = undefined;
327
+ if (this.isUserJoinedFromAnotherSocket === false && this.selfParticipant && this.selfParticipant.roomId && this.selfParticipant.userId) {
328
+ if (this.numberOfPongWaiting > 10) {
326
329
  console.log("No Pong More Than 8 Times start");
327
330
  console.log(this.selfParticipant);
328
331
  console.log("No Pong More Than 8 Times End");
@@ -330,10 +333,13 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
330
333
  this.onUserLeft();
331
334
  return;
332
335
  }
333
- this.redisBroadcastMessageToTopic(this.selfParticipant.userId, this.preapreClientMessageBody(true, this.selfParticipant, this.preapreWebSocketMessageBody(WebSocketBasicEvents.Ping, { userId: this.selfParticipant.userId })));
334
- this.numberOfPongWaiting = this.numberOfPongWaiting + 1;
335
- console.log("Pong", this.numberOfPongWaiting);
336
- setTimeout(this.startPingPong, 5000);
336
+ const user = await RedisHandler_1.RedisHandler.getInstance().getParticipantByUserId(this.selfParticipant.roomId, this.selfParticipant.userId);
337
+ if (this.pingPongTimeout === undefined && user) {
338
+ this.redisBroadcastMessageToTopic(this.selfParticipant.userId, this.preapreClientMessageBody(true, this.selfParticipant, this.preapreWebSocketMessageBody(WebSocketBasicEvents.Ping, { userId: this.selfParticipant.userId })));
339
+ this.numberOfPongWaiting = this.numberOfPongWaiting + 1;
340
+ console.log("Pong", this.numberOfPongWaiting);
341
+ this.pingPongTimeout = setTimeout(this.startPingPong, 5000);
342
+ }
337
343
  }
338
344
  }
339
345
  cleanUp() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-server",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "Vani Meeting Server SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",