vani-meeting-server 2.9.9 → 3.0.1

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.
@@ -39,7 +39,7 @@ export declare class RedisHandler {
39
39
  removeParticipantForRoom(roomId: string, participant: Participant): Promise<undefined>;
40
40
  addUpdateParticipantForRoom(roomId: string, participant: Participant): Promise<undefined>;
41
41
  getParticipantByUserId(roomId: string, userId: string): Promise<Participant | undefined>;
42
- getAllParticipants(roomId: string): Promise<Participant[]>;
42
+ getAllParticipants(roomId: string, canFetchFromLocal?: boolean): Promise<Participant[]>;
43
43
  getAllRoomsId(): Promise<string[] | undefined>;
44
44
  private updateRoomCleanupTimeOut;
45
45
  releaseRedis: () => Promise<void>;
@@ -172,6 +172,12 @@ class RedisHandler {
172
172
  };
173
173
  getKeyValueForLocalCache = (key, fieldOne) => {
174
174
  const keyData = this.localCacheDataStorage.get(key);
175
+ if (!fieldOne) {
176
+ if (keyData) {
177
+ return keyData;
178
+ }
179
+ return undefined;
180
+ }
175
181
  if (keyData && keyData.has(fieldOne)) {
176
182
  const data = keyData.get(fieldOne);
177
183
  // ServerHandler.getInstance().serverStartRequest && ServerHandler.getInstance().serverStartRequest.logLevel !== LogLevel.None && console.log("CachedRedisResponse", data)
@@ -388,9 +394,23 @@ class RedisHandler {
388
394
  return undefined;
389
395
  }
390
396
  }
391
- async getAllParticipants(roomId) {
397
+ async getAllParticipants(roomId, canFetchFromLocal = true) {
398
+ let particpantsInStringify;
392
399
  try {
393
- const particpantsInStringify = await this.redisClient.hGetAll(roomId);
400
+ try {
401
+ if (canFetchFromLocal) {
402
+ const localCacheMessages = this.getKeyValueForLocalCache(roomId);
403
+ if (localCacheMessages) {
404
+ particpantsInStringify = localCacheMessages;
405
+ console.log("getAllParticipants from cache", particpantsInStringify, canFetchFromLocal);
406
+ }
407
+ }
408
+ }
409
+ catch (err) {
410
+ }
411
+ if (!particpantsInStringify) {
412
+ particpantsInStringify = await this.redisClient.hGetAll(roomId);
413
+ }
394
414
  const participants = [];
395
415
  if (particpantsInStringify) {
396
416
  Object.entries(particpantsInStringify).forEach(([key, value]) => {
@@ -400,6 +420,9 @@ class RedisHandler {
400
420
  }
401
421
  });
402
422
  }
423
+ if (participants.length === 0 && !canFetchFromLocal) {
424
+ return this.getAllParticipants(roomId, false);
425
+ }
403
426
  return participants;
404
427
  }
405
428
  catch (err) {
@@ -391,10 +391,12 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
391
391
  }
392
392
  async getAllParticipants() {
393
393
  const allUsers = await RedisHandler_1.RedisHandler.getInstance().getAllParticipants(this.selfParticipant?.roomId);
394
+ ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("getAllParticipants", allUsers);
394
395
  const userMap = {};
395
396
  allUsers.forEach((participant) => {
396
397
  userMap[participant.userId] = participant;
397
398
  });
399
+ ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("getAllParticipants usermao", userMap);
398
400
  this.redisBroadcastMessageToTopic(this.selfParticipant.userId, this.preapreClientMessageBody(true, this.selfParticipant, this.preapreWebSocketMessageBody(WebSocketBasicEvents.OnServerParticipants, userMap)));
399
401
  }
400
402
  async startPingPong() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-server",
3
- "version": "2.9.9",
3
+ "version": "3.0.1",
4
4
  "description": "Vani Meeting Server SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",