vani-meeting-server 2.0.4 → 2.0.5

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.
@@ -50,6 +50,7 @@ class RedisHandler {
50
50
  }
51
51
  //Clean Room Id
52
52
  async cleanUpRoomId(roomId) {
53
+ console.log("Cleanup Room From Redis");
53
54
  await this.redisClient.del(roomId);
54
55
  }
55
56
  //ip addresss
@@ -5,6 +5,7 @@ import { Participant } from "./Participant";
5
5
  export declare enum VaniEvent {
6
6
  OnNewMeetingStarted = "onNewMeetingStarted",
7
7
  OnNewMeetingEnded = "onNewMeetingEnded",
8
+ OnAllParticipantLeftOnServer = "OnAllParticipantLeftOnServer",
8
9
  OnUserJoined = "onUserJoined",
9
10
  OnUserLeft = "onUserLeft",
10
11
  OnServerStarted = "onServerStarted",
@@ -16,6 +17,7 @@ export declare enum VaniEvent {
16
17
  interface VaniConnectionEvents {
17
18
  [VaniEvent.OnNewMeetingStarted]: (roomId: string) => any;
18
19
  [VaniEvent.OnNewMeetingEnded]: (roomId: string) => any;
20
+ [VaniEvent.OnAllParticipantLeftOnServer]: (roomId: string) => any;
19
21
  [VaniEvent.OnUserJoined]: (participant: Participant) => any;
20
22
  [VaniEvent.OnUserLeft]: (participant: Participant) => any;
21
23
  [VaniEvent.OnServerStarted]: () => any;
@@ -5,6 +5,7 @@ var VaniEvent;
5
5
  (function (VaniEvent) {
6
6
  VaniEvent["OnNewMeetingStarted"] = "onNewMeetingStarted";
7
7
  VaniEvent["OnNewMeetingEnded"] = "onNewMeetingEnded";
8
+ VaniEvent["OnAllParticipantLeftOnServer"] = "OnAllParticipantLeftOnServer";
8
9
  VaniEvent["OnUserJoined"] = "onUserJoined";
9
10
  VaniEvent["OnUserLeft"] = "onUserLeft";
10
11
  VaniEvent["OnServerStarted"] = "onServerStarted";
@@ -68,5 +68,5 @@ export declare class SFUEachRoomHandler extends BaseSFUWebsocket implements SFUE
68
68
  resumeAllBroadcastingConsumers(): Promise<void>;
69
69
  startBroadcasting(plainTransportPayload: PlainTransportPayload): Promise<void>;
70
70
  private consumeProducerForPlainTransport;
71
- cleanUp(): void;
71
+ cleanUp(): Promise<void>;
72
72
  }
@@ -371,12 +371,24 @@ class SFUEachRoomHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
371
371
  }
372
372
  }
373
373
  }
374
- cleanUp() {
374
+ async cleanUp() {
375
375
  console.debug("Clean Up Room Id ", this.roomId);
376
- RedisHandler_1.RedisHandler.getInstance().cleanUpRoomId(this.roomId);
376
+ const allParticipants = await RedisHandler_1.RedisHandler.getInstance().getAllParticipants(this.roomId);
377
+ let shouldCleanupRedis = true;
378
+ if (allParticipants && allParticipants.length > 0) {
379
+ const selfIpAddress = await Constant_1.default.getPublicIp();
380
+ const participantOnOtherServer = allParticipants.filter((eachParticipant) => eachParticipant.serverIpAddress !== selfIpAddress);
381
+ if (participantOnOtherServer && participantOnOtherServer.length > 0) {
382
+ shouldCleanupRedis = false;
383
+ }
384
+ }
385
+ if (shouldCleanupRedis) {
386
+ RedisHandler_1.RedisHandler.getInstance().cleanUpRoomId(this.roomId);
387
+ EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.emit(Event_1.VaniEvent.OnNewMeetingEnded, this.roomId);
388
+ }
389
+ EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.emit(Event_1.VaniEvent.OnAllParticipantLeftOnServer, this.roomId);
377
390
  this.eachRoomMutliserverHandler?.cleanUp();
378
391
  this.eachRoomMutliserverHandler = undefined;
379
- EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.emit(Event_1.VaniEvent.OnNewMeetingEnded, this.roomId);
380
392
  this.roomPaticipants.forEach((sfuEachRoomUser) => {
381
393
  this.onUserLeft(sfuEachRoomUser.selfParticipant);
382
394
  });
@@ -9,7 +9,7 @@ export declare class SFUHandler {
9
9
  constructor();
10
10
  init(): Promise<void>;
11
11
  checkAndSetupRoom(roomId: string, connectionProtocol: ConnectionProtocol): Promise<void>;
12
- checkIfCanCloseRoom(roomId: string): void;
12
+ checkIfCanCloseRoom(roomId: string): Promise<void>;
13
13
  getRoomSFUHandler(roomId: string): SFUEachRoomHandler | undefined;
14
14
  startPlainTransportForBroadcasting(plainTransportPayload: PlainTransportPayload, forRoomid: string): Promise<void>;
15
15
  resumeAllBroadcastingConsumers(forRoomid: string): Promise<void>;
@@ -51,10 +51,10 @@ class SFUHandler {
51
51
  this.sfuRooms.set(roomId, sfuEachRoomHandler);
52
52
  }
53
53
  }
54
- checkIfCanCloseRoom(roomId) {
54
+ async checkIfCanCloseRoom(roomId) {
55
55
  const room = this.getRoomSFUHandler(roomId);
56
56
  if (room && room.roomPaticipants.size === 0) {
57
- room.cleanUp();
57
+ await room.cleanUp();
58
58
  this.sfuRooms.delete(roomId);
59
59
  }
60
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vani-meeting-server",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Vani Meeting Server SDK",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",