vani-meeting-server 2.0.8 → 2.1.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.
|
@@ -46,6 +46,7 @@ export declare class SFUEachRoomHandler extends BaseSFUWebsocket implements SFUE
|
|
|
46
46
|
private audioObserver?;
|
|
47
47
|
private connectionProtocol;
|
|
48
48
|
private eachRoomMutliserverHandler?;
|
|
49
|
+
private redisSubscribtionDetails;
|
|
49
50
|
constructor(roomId: string, workers: Worker[], sendWorkerIndex: number, connectionProtocol?: ConnectionProtocol);
|
|
50
51
|
onInit: () => Promise<void>;
|
|
51
52
|
getConnectionProtocolType(): ConnectionProtocol;
|
|
@@ -68,5 +69,7 @@ export declare class SFUEachRoomHandler extends BaseSFUWebsocket implements SFUE
|
|
|
68
69
|
resumeAllBroadcastingConsumers(): Promise<void>;
|
|
69
70
|
startBroadcasting(plainTransportPayload: PlainTransportPayload): Promise<void>;
|
|
70
71
|
private consumeProducerForPlainTransport;
|
|
72
|
+
private redisSubscribeToTopic;
|
|
73
|
+
private onRedisMessage;
|
|
71
74
|
cleanUp(): Promise<void>;
|
|
72
75
|
}
|
|
@@ -49,6 +49,7 @@ class SFUEachRoomHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
49
49
|
audioObserver;
|
|
50
50
|
connectionProtocol = ServerHandler_1.ServerHandler.getInstance().serverStartRequest.connectionProtocol;
|
|
51
51
|
eachRoomMutliserverHandler;
|
|
52
|
+
redisSubscribtionDetails = [];
|
|
52
53
|
constructor(roomId, workers, sendWorkerIndex, connectionProtocol) {
|
|
53
54
|
super();
|
|
54
55
|
this.roomId = roomId;
|
|
@@ -63,6 +64,7 @@ class SFUEachRoomHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
63
64
|
this.onInit();
|
|
64
65
|
}
|
|
65
66
|
onInit = async () => {
|
|
67
|
+
await this.redisSubscribeToTopic(Utility_1.Utility.getTopicForRoomIdAndIp(this.roomId, await Constant_1.default.getPublicIp()));
|
|
66
68
|
await this.setUpForRoomId(this.workers, this.sendWorkerIndex);
|
|
67
69
|
if (this.sendRouter) {
|
|
68
70
|
this.eachRoomMutliserverHandler = new SFUEachRoomMutliServerHandler_1.SFUEachRoomMutliServerHandler(this.roomId, this.sendRouter, this);
|
|
@@ -372,6 +374,25 @@ class SFUEachRoomHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
372
374
|
}
|
|
373
375
|
}
|
|
374
376
|
}
|
|
377
|
+
async redisSubscribeToTopic(topic) {
|
|
378
|
+
const isListenerAlreadyExist = this.redisSubscribtionDetails.find((eachRedisSubscribtionDetails) => eachRedisSubscribtionDetails.topic === topic);
|
|
379
|
+
if (!isListenerAlreadyExist) {
|
|
380
|
+
const listener = (data) => {
|
|
381
|
+
this.onRedisMessage(JSON.parse(data));
|
|
382
|
+
};
|
|
383
|
+
await RedisHandler_1.RedisHandler.getInstance().redisSubscriber.subscribe(topic, listener);
|
|
384
|
+
this.redisSubscribtionDetails.push({ topic, listener });
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
onRedisMessage = async (data) => {
|
|
388
|
+
if (data.interfaceName === 'MultiSystemEventsBody') {
|
|
389
|
+
console.log("MultiSystemEventsBody recived ", data);
|
|
390
|
+
const multiSystemEvent = data;
|
|
391
|
+
if (multiSystemEvent.roomId === this.roomId) {
|
|
392
|
+
this.onMutiRoomMessage(multiSystemEvent);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
};
|
|
375
396
|
async cleanUp() {
|
|
376
397
|
console.debug("Clean Up Room Id ", this.roomId);
|
|
377
398
|
const allParticipants = await RedisHandler_1.RedisHandler.getInstance().getAllParticipants(this.roomId);
|
|
@@ -389,6 +410,10 @@ class SFUEachRoomHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
389
410
|
}
|
|
390
411
|
EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.emit(Event_1.VaniEvent.OnAllParticipantLeftOnServer, this.roomId);
|
|
391
412
|
RedisHandler_1.RedisHandler.getInstance().deleteIpForRoomId(this.roomId, await Constant_1.default.getPublicIp());
|
|
413
|
+
this.redisSubscribtionDetails.forEach((eachRedisSubscribtionDetails) => {
|
|
414
|
+
RedisHandler_1.RedisHandler.getInstance().redisSubscriber.unsubscribe(eachRedisSubscribtionDetails.topic, eachRedisSubscribtionDetails.listener);
|
|
415
|
+
});
|
|
416
|
+
this.redisSubscribtionDetails = [];
|
|
392
417
|
this.eachRoomMutliserverHandler?.cleanUp();
|
|
393
418
|
this.eachRoomMutliserverHandler = undefined;
|
|
394
419
|
this.roomPaticipants.forEach((sfuEachRoomUser) => {
|
|
@@ -407,14 +407,14 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
407
407
|
const socketMessageBody = data;
|
|
408
408
|
this.sendMessageToClient(socketMessageBody);
|
|
409
409
|
}
|
|
410
|
-
else if (data.interfaceName === 'MultiSystemEventsBody') {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
410
|
+
// else if (data.interfaceName === 'MultiSystemEventsBody') {
|
|
411
|
+
// console.log("MultiSystemEventsBody recived ", data)
|
|
412
|
+
// const multiSystemEvent: MultiSystemEventsBody = data
|
|
413
|
+
// const roomSFUHandler = SFUHandler.getInstance().getRoomSFUHandler(multiSystemEvent.roomId)
|
|
414
|
+
// if (roomSFUHandler) {
|
|
415
|
+
// roomSFUHandler.onMutiRoomMessage(multiSystemEvent)
|
|
416
|
+
// }
|
|
417
|
+
// }
|
|
418
418
|
}
|
|
419
419
|
async subscribeToRedisMessages() {
|
|
420
420
|
RedisHandler_1.RedisHandler.getInstance().redisSubscriber.on('message', (roomId, messageInString) => {
|