vani-meeting-server 2.8.7 → 2.8.8
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.
- package/lib/ServerHandler.d.ts +1 -0
- package/lib/ServerHandler.js +1 -0
- package/lib/base/BaseSFUWebsocket.js +8 -4
- package/lib/lib/redis/RedisHandler.d.ts +5 -0
- package/lib/lib/redis/RedisHandler.js +62 -11
- package/lib/models/Event.d.ts +2 -0
- package/lib/models/Event.js +1 -0
- package/lib/sfu/SFUEachRoomHandler.d.ts +1 -0
- package/lib/sfu/SFUEachRoomHandler.js +14 -1
- package/lib/utility/Constant.d.ts +2 -2
- package/lib/websocket/EachSocketConnectionHandler.d.ts +4 -0
- package/lib/websocket/EachSocketConnectionHandler.js +19 -5
- package/package.json +3 -3
package/lib/ServerHandler.d.ts
CHANGED
package/lib/ServerHandler.js
CHANGED
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseSFUWebsocket = void 0;
|
|
4
4
|
const RedisHandler_1 = require("../lib/redis/RedisHandler");
|
|
5
|
+
const ServerHandler_1 = require("../ServerHandler");
|
|
6
|
+
const EventEmitterHandler_1 = require("../utility/EventEmitterHandler");
|
|
5
7
|
class BaseSFUWebsocket {
|
|
6
8
|
async redisBroadcastMessageToTopic(topic, data) {
|
|
7
|
-
|
|
9
|
+
const stringifyData = JSON.stringify(data);
|
|
10
|
+
RedisHandler_1.RedisHandler.getInstance().redisPublisher.publish(topic, stringifyData);
|
|
11
|
+
EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.emit(topic, stringifyData);
|
|
8
12
|
}
|
|
9
13
|
//Utilility function
|
|
10
14
|
prepareMutilSystemEvents(multiSystemEvent, roomId, data) {
|
|
11
|
-
return { type: multiSystemEvent, interfaceName: 'MultiSystemEventsBody', data: data, roomId: roomId };
|
|
15
|
+
return { type: multiSystemEvent, interfaceName: 'MultiSystemEventsBody', data: data, roomId: roomId, senderUUID: ServerHandler_1.ServerHandler.getInstance().serverUUID };
|
|
12
16
|
}
|
|
13
17
|
preapreClientMessageBody(shouldSendToSelf, senderParticipant, broadcastMessage) {
|
|
14
|
-
return { shouldSendToSelf, senderParticipant, broadcastMessage, interfaceName: 'ClientMessageBody' };
|
|
18
|
+
return { shouldSendToSelf, senderParticipant, broadcastMessage, interfaceName: 'ClientMessageBody', senderUUID: ServerHandler_1.ServerHandler.getInstance().serverUUID };
|
|
15
19
|
}
|
|
16
20
|
preapreWebSocketMessageBody(type, data) {
|
|
17
|
-
return { type, data, interfaceName: 'WebSocketMessageBody' };
|
|
21
|
+
return { type, data, interfaceName: 'WebSocketMessageBody', senderUUID: ServerHandler_1.ServerHandler.getInstance().serverUUID };
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
exports.BaseSFUWebsocket = BaseSFUWebsocket;
|
|
@@ -10,6 +10,7 @@ export declare enum RedisKeyType {
|
|
|
10
10
|
export declare class RedisHandler {
|
|
11
11
|
private static redisHandler?;
|
|
12
12
|
private redisClient;
|
|
13
|
+
private localCacheDataStorage;
|
|
13
14
|
redisPublisher: RedisClientType;
|
|
14
15
|
redisSubscriber: RedisClientType;
|
|
15
16
|
static getInstance(): RedisHandler;
|
|
@@ -18,6 +19,9 @@ export declare class RedisHandler {
|
|
|
18
19
|
connectDB(): Promise<void>;
|
|
19
20
|
cleanUp(): Promise<string | undefined>;
|
|
20
21
|
cleanUpRoomId(roomId: string): Promise<void>;
|
|
22
|
+
private deleteKeyValueForLocalCache;
|
|
23
|
+
private getKeyValueForLocalCache;
|
|
24
|
+
private storeKeyValueForLocalCache;
|
|
21
25
|
setIpForRoomId(roomId: string, ipAddress: string): Promise<void>;
|
|
22
26
|
fetchIpsForRoomId(roomId: string): Promise<{
|
|
23
27
|
ip: string;
|
|
@@ -35,4 +39,5 @@ export declare class RedisHandler {
|
|
|
35
39
|
getAllRoomsId(): Promise<string[] | undefined>;
|
|
36
40
|
private updateRoomCleanupTimeOut;
|
|
37
41
|
releaseRedis: () => Promise<void>;
|
|
42
|
+
private cleanupLocalCache;
|
|
38
43
|
}
|
|
@@ -19,7 +19,7 @@ var RedisKeyType;
|
|
|
19
19
|
class RedisHandler {
|
|
20
20
|
static redisHandler = new RedisHandler();
|
|
21
21
|
redisClient;
|
|
22
|
-
|
|
22
|
+
localCacheDataStorage = new Map;
|
|
23
23
|
redisPublisher;
|
|
24
24
|
redisSubscriber;
|
|
25
25
|
static getInstance() {
|
|
@@ -98,17 +98,19 @@ class RedisHandler {
|
|
|
98
98
|
async cleanUp() {
|
|
99
99
|
try {
|
|
100
100
|
if (ServerHandler_1.ServerHandler.getInstance().serverStartRequest.shouldCleanRedisOnStartUp) {
|
|
101
|
+
this.localCacheDataStorage = new Map;
|
|
101
102
|
return await this.redisClient.flushDb();
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
catch (err) {
|
|
105
|
-
console.log("cleanUp", err)
|
|
106
|
+
// console.log("cleanUp", err)
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
//Clean Room Id
|
|
109
110
|
async cleanUpRoomId(roomId) {
|
|
110
111
|
try {
|
|
111
112
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("Cleanup Room From Redis");
|
|
113
|
+
this.localCacheDataStorage.delete(roomId);
|
|
112
114
|
await this.redisClient.del(roomId);
|
|
113
115
|
}
|
|
114
116
|
catch (err) {
|
|
@@ -116,6 +118,31 @@ class RedisHandler {
|
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
//ip addresss
|
|
121
|
+
deleteKeyValueForLocalCache = (key, fieldOne) => {
|
|
122
|
+
if (!fieldOne) {
|
|
123
|
+
this.localCacheDataStorage.delete(key);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
if (this.localCacheDataStorage.has(key)) {
|
|
127
|
+
this.localCacheDataStorage.get(key)?.delete(fieldOne);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
getKeyValueForLocalCache = (key, fieldOne) => {
|
|
132
|
+
const keyData = this.localCacheDataStorage.get(key);
|
|
133
|
+
if (keyData && keyData.has(fieldOne)) {
|
|
134
|
+
return keyData.get(fieldOne);
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
};
|
|
138
|
+
storeKeyValueForLocalCache = (key, fieldOne, fieldTwo) => {
|
|
139
|
+
let keyData = this.localCacheDataStorage.get(key);
|
|
140
|
+
if (!keyData) {
|
|
141
|
+
keyData = new Map();
|
|
142
|
+
this.localCacheDataStorage.set(key, keyData);
|
|
143
|
+
}
|
|
144
|
+
keyData.set(fieldOne, fieldTwo);
|
|
145
|
+
};
|
|
119
146
|
async setIpForRoomId(roomId, ipAddress) {
|
|
120
147
|
try {
|
|
121
148
|
const oldIps = await this.fetchIpsForRoomId(roomId);
|
|
@@ -125,9 +152,10 @@ class RedisHandler {
|
|
|
125
152
|
return;
|
|
126
153
|
}
|
|
127
154
|
oldIps.push({ ip: ipAddress, port: ServerHandler_1.ServerHandler.getInstance().serverStartRequest.port });
|
|
128
|
-
|
|
155
|
+
this.storeKeyValueForLocalCache(roomId, RedisKeyType.IpAddress, JSON.stringify(oldIps));
|
|
156
|
+
/*await*/ this.redisClient.hSet(roomId, RedisKeyType.IpAddress, JSON.stringify(oldIps));
|
|
129
157
|
this.updateRoomCleanupTimeOut(roomId);
|
|
130
|
-
await this.fetchIpsForRoomId(roomId)
|
|
158
|
+
// await this.fetchIpsForRoomId(roomId)
|
|
131
159
|
}
|
|
132
160
|
catch (err) {
|
|
133
161
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("setIpForRoomId", err);
|
|
@@ -138,7 +166,8 @@ class RedisHandler {
|
|
|
138
166
|
// this.fetchIpsForRoomId(roomId)
|
|
139
167
|
// }, 10000)
|
|
140
168
|
try {
|
|
141
|
-
const
|
|
169
|
+
const localCacheRedisData = this.getKeyValueForLocalCache(roomId, RedisKeyType.IpAddress);
|
|
170
|
+
const ipAddress = localCacheRedisData ? localCacheRedisData : await this.redisClient.hGet(roomId, RedisKeyType.IpAddress);
|
|
142
171
|
if (ipAddress) {
|
|
143
172
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("fetchIpsForRoomId", JSON.parse(ipAddress));
|
|
144
173
|
return JSON.parse(ipAddress);
|
|
@@ -157,7 +186,8 @@ class RedisHandler {
|
|
|
157
186
|
try {
|
|
158
187
|
const oldIps = await this.fetchIpsForRoomId(roomId);
|
|
159
188
|
const newIps = oldIps.filter((eachOldIp) => !(eachOldIp.ip === ipAddress && eachOldIp.port === ServerHandler_1.ServerHandler.getInstance().serverStartRequest.port));
|
|
160
|
-
|
|
189
|
+
this.storeKeyValueForLocalCache(roomId, RedisKeyType.IpAddress, JSON.stringify(newIps));
|
|
190
|
+
/*await*/ this.redisClient.hSet(roomId, RedisKeyType.IpAddress, JSON.stringify(newIps));
|
|
161
191
|
this.updateRoomCleanupTimeOut(roomId);
|
|
162
192
|
}
|
|
163
193
|
catch (err) {
|
|
@@ -169,6 +199,7 @@ class RedisHandler {
|
|
|
169
199
|
try {
|
|
170
200
|
const messages = await this.fetchMessagesForRoom(roomId);
|
|
171
201
|
messages.push(messagePayload);
|
|
202
|
+
// this.storeKeyValueForLocalCache(roomId, RedisKeyType.Messages, JSON.stringify(messages))
|
|
172
203
|
await this.redisClient.hSet(roomId, RedisKeyType.Messages, JSON.stringify(messages));
|
|
173
204
|
this.updateRoomCleanupTimeOut(roomId);
|
|
174
205
|
}
|
|
@@ -178,7 +209,8 @@ class RedisHandler {
|
|
|
178
209
|
}
|
|
179
210
|
async fetchMessagesForRoom(roomId) {
|
|
180
211
|
try {
|
|
181
|
-
const
|
|
212
|
+
// const localCacheMessages = this.getKeyValueForLocalCache(roomId, RedisKeyType.Messages)
|
|
213
|
+
const messages = /*localCacheMessages ? localCacheMessages : */ await this.redisClient.hGet(roomId, RedisKeyType.Messages);
|
|
182
214
|
if (messages) {
|
|
183
215
|
return JSON.parse(messages);
|
|
184
216
|
}
|
|
@@ -194,7 +226,8 @@ class RedisHandler {
|
|
|
194
226
|
//Meeting Time
|
|
195
227
|
async storeMeetingTimeForRoom(roomId, time) {
|
|
196
228
|
try {
|
|
197
|
-
|
|
229
|
+
this.storeKeyValueForLocalCache(roomId, RedisKeyType.MeetingTime, time ? time : new Date().getTime());
|
|
230
|
+
/*await*/ this.redisClient.hSet(roomId, RedisKeyType.MeetingTime, time ? time : new Date().getTime());
|
|
198
231
|
this.updateRoomCleanupTimeOut(roomId);
|
|
199
232
|
}
|
|
200
233
|
catch (err) {
|
|
@@ -204,7 +237,8 @@ class RedisHandler {
|
|
|
204
237
|
}
|
|
205
238
|
async fetchMeetingTimeForRoom(roomId) {
|
|
206
239
|
try {
|
|
207
|
-
const
|
|
240
|
+
const localCacheMessages = this.getKeyValueForLocalCache(roomId, RedisKeyType.MeetingTime);
|
|
241
|
+
const meetingTime = localCacheMessages ? localCacheMessages : await this.redisClient.hGet(roomId, RedisKeyType.MeetingTime);
|
|
208
242
|
if (meetingTime) {
|
|
209
243
|
return +meetingTime;
|
|
210
244
|
}
|
|
@@ -222,6 +256,7 @@ class RedisHandler {
|
|
|
222
256
|
try {
|
|
223
257
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("removeParticipantForRoom", participant);
|
|
224
258
|
const participantKey = RedisKeyType.Participants + ":" + participant.userId;
|
|
259
|
+
this.deleteKeyValueForLocalCache(roomId, participantKey);
|
|
225
260
|
await this.redisClient.hDel(roomId, participantKey);
|
|
226
261
|
// console.log("removeParticipantForRoom =====" , participantKey)
|
|
227
262
|
// console.log(await this.getAllParticipants(roomId))
|
|
@@ -240,7 +275,8 @@ class RedisHandler {
|
|
|
240
275
|
if (!participant.serverIpAddress) {
|
|
241
276
|
participant.serverIpAddress = await Constant_1.default.getPublicIp();
|
|
242
277
|
}
|
|
243
|
-
|
|
278
|
+
this.storeKeyValueForLocalCache(roomId, participantKey, JSON.stringify(participant));
|
|
279
|
+
/*await*/ this.redisClient.hSet(roomId, participantKey, JSON.stringify(participant));
|
|
244
280
|
// console.log("addUpdateParticipantForRoom =====" , participantKey)
|
|
245
281
|
// console.log(await this.getAllParticipants(roomId))
|
|
246
282
|
// console.log("addUpdateParticipantForRoom +++++")
|
|
@@ -254,7 +290,8 @@ class RedisHandler {
|
|
|
254
290
|
async getParticipantByUserId(roomId, userId) {
|
|
255
291
|
try {
|
|
256
292
|
const participantKey = RedisKeyType.Participants + ":" + userId;
|
|
257
|
-
const
|
|
293
|
+
const cahcedLocalData = this.getKeyValueForLocalCache(roomId, participantKey);
|
|
294
|
+
const particpantString = cahcedLocalData ? cahcedLocalData : await this.redisClient.hGet(roomId, participantKey);
|
|
258
295
|
if (particpantString) {
|
|
259
296
|
return JSON.parse(particpantString);
|
|
260
297
|
}
|
|
@@ -310,12 +347,26 @@ class RedisHandler {
|
|
|
310
347
|
catch (err) {
|
|
311
348
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("updateRoomCleanupTimeOut", err);
|
|
312
349
|
}
|
|
350
|
+
try {
|
|
351
|
+
this.cleanupLocalCache();
|
|
352
|
+
}
|
|
353
|
+
catch (e) {
|
|
354
|
+
}
|
|
313
355
|
}
|
|
314
356
|
releaseRedis = async () => {
|
|
315
357
|
RedisHandler.redisHandler = undefined;
|
|
316
358
|
this.redisClient.disconnect();
|
|
317
359
|
this.redisPublisher.disconnect();
|
|
318
360
|
this.redisSubscriber.disconnect();
|
|
361
|
+
this.cleanupLocalCache();
|
|
362
|
+
};
|
|
363
|
+
cleanupLocalCache = async () => {
|
|
364
|
+
try {
|
|
365
|
+
if (this.localCacheDataStorage && this.localCacheDataStorage.size > 1000) {
|
|
366
|
+
this.localCacheDataStorage = new Map();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
catch (err) { }
|
|
319
370
|
};
|
|
320
371
|
}
|
|
321
372
|
exports.RedisHandler = RedisHandler;
|
package/lib/models/Event.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Participant } from "./Participant";
|
|
|
5
5
|
export declare enum VaniEvent {
|
|
6
6
|
OnNewMeetingStarted = "onNewMeetingStarted",
|
|
7
7
|
OnNewMeetingEnded = "onNewMeetingEnded",
|
|
8
|
+
OnLocalRedisMessage = "onLocalRedisMessage",
|
|
8
9
|
OnNewMeetingStartedOnCurrentServer = "OnNewMeetingStartedOnCurrentServer",
|
|
9
10
|
OnAllParticipantLeftOnServer = "OnAllParticipantLeftOnServer",
|
|
10
11
|
OnUserJoined = "onUserJoined",
|
|
@@ -24,6 +25,7 @@ interface VaniConnectionEvents {
|
|
|
24
25
|
[VaniEvent.OnNewMeetingEnded]: (roomId: string) => any;
|
|
25
26
|
[VaniEvent.OnAllParticipantLeftOnServer]: (roomId: string) => any;
|
|
26
27
|
[VaniEvent.OnUserJoined]: (participant: Participant) => any;
|
|
28
|
+
[VaniEvent.OnLocalRedisMessage]: (message: any) => any;
|
|
27
29
|
[VaniEvent.OnUserLeft]: (participant: Participant) => any;
|
|
28
30
|
[VaniEvent.OnServerStarted]: () => any;
|
|
29
31
|
[VaniEvent.OnPlainTransportCreated]: (plainTransportCreatedCallback: PlainTransportCreatedCallback) => any;
|
package/lib/models/Event.js
CHANGED
|
@@ -5,6 +5,7 @@ var VaniEvent;
|
|
|
5
5
|
(function (VaniEvent) {
|
|
6
6
|
VaniEvent["OnNewMeetingStarted"] = "onNewMeetingStarted";
|
|
7
7
|
VaniEvent["OnNewMeetingEnded"] = "onNewMeetingEnded";
|
|
8
|
+
VaniEvent["OnLocalRedisMessage"] = "onLocalRedisMessage";
|
|
8
9
|
VaniEvent["OnNewMeetingStartedOnCurrentServer"] = "OnNewMeetingStartedOnCurrentServer";
|
|
9
10
|
VaniEvent["OnAllParticipantLeftOnServer"] = "OnAllParticipantLeftOnServer";
|
|
10
11
|
VaniEvent["OnUserJoined"] = "onUserJoined";
|
|
@@ -75,6 +75,7 @@ export declare class SFUEachRoomHandler extends BaseSFUWebsocket implements SFUE
|
|
|
75
75
|
createPlainTransportAndConsumeProducer: (plainTransportPayload: PlainTransportPayload, producer: Producer) => Promise<void>;
|
|
76
76
|
private consumeProducerForPlainTransport;
|
|
77
77
|
private redisSubscribeToTopic;
|
|
78
|
+
private onLocalRedisMessage;
|
|
78
79
|
private onRedisMessage;
|
|
79
80
|
cleanUp(): Promise<void>;
|
|
80
81
|
}
|
|
@@ -489,12 +489,24 @@ class SFUEachRoomHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
489
489
|
const isListenerAlreadyExist = this.redisSubscribtionDetails.find((eachRedisSubscribtionDetails) => eachRedisSubscribtionDetails.topic === topic);
|
|
490
490
|
if (!isListenerAlreadyExist) {
|
|
491
491
|
const listener = (data) => {
|
|
492
|
-
this.onRedisMessage(JSON.parse(data))
|
|
492
|
+
// this.onRedisMessage(JSON.parse(data))
|
|
493
|
+
const parsedData = JSON.parse(data);
|
|
494
|
+
if (parsedData && parsedData.senderUUID && parsedData.senderUUID === ServerHandler_1.ServerHandler.getInstance().serverUUID) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
this.onRedisMessage(parsedData);
|
|
493
498
|
};
|
|
494
499
|
await RedisHandler_1.RedisHandler.getInstance().redisSubscriber.subscribe(topic, listener);
|
|
500
|
+
EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.on(topic, this.onLocalRedisMessage);
|
|
495
501
|
this.redisSubscribtionDetails.push({ topic, listener });
|
|
496
502
|
}
|
|
497
503
|
}
|
|
504
|
+
onLocalRedisMessage = async (data) => {
|
|
505
|
+
const stringifiedData = data;
|
|
506
|
+
if (stringifiedData) {
|
|
507
|
+
this.onRedisMessage(JSON.parse(stringifiedData));
|
|
508
|
+
}
|
|
509
|
+
};
|
|
498
510
|
onRedisMessage = async (data) => {
|
|
499
511
|
if (data.interfaceName === 'MultiSystemEventsBody') {
|
|
500
512
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("MultiSystemEventsBody recived ", data);
|
|
@@ -523,6 +535,7 @@ class SFUEachRoomHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
523
535
|
RedisHandler_1.RedisHandler.getInstance().deleteIpForRoomId(this.roomId, await Constant_1.default.getPublicIp());
|
|
524
536
|
this.redisSubscribtionDetails.forEach((eachRedisSubscribtionDetails) => {
|
|
525
537
|
RedisHandler_1.RedisHandler.getInstance().redisSubscriber.unsubscribe(eachRedisSubscribtionDetails.topic, eachRedisSubscribtionDetails.listener);
|
|
538
|
+
EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.off(eachRedisSubscribtionDetails.topic, this.onLocalRedisMessage);
|
|
526
539
|
});
|
|
527
540
|
this.redisSubscribtionDetails = [];
|
|
528
541
|
this.eachRoomMutliserverHandler?.cleanUp();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RouterRtpCodecCapability } from "mediasoup/node/lib/rtpParametersTypes";
|
|
2
2
|
import { ConnectionProtocol } from "../models/WebSocketServerStartRequest";
|
|
3
|
-
export declare const mediaCodecs:
|
|
3
|
+
export declare const mediaCodecs: RouterRtpCodecCapability[];
|
|
4
4
|
export declare function webrtcTransportConfiguration(perferProtocol: ConnectionProtocol): Promise<{
|
|
5
5
|
listenIps: {
|
|
6
6
|
ip: string;
|
|
@@ -91,18 +91,21 @@ export interface WebSocketMessageBody {
|
|
|
91
91
|
interfaceName: 'WebSocketMessageBody';
|
|
92
92
|
type: WebSocketEvents;
|
|
93
93
|
data?: any;
|
|
94
|
+
senderUUID?: any;
|
|
94
95
|
}
|
|
95
96
|
export interface MultiSystemEventsBody {
|
|
96
97
|
interfaceName: 'MultiSystemEventsBody';
|
|
97
98
|
type: MultiSystemEvents;
|
|
98
99
|
data?: any;
|
|
99
100
|
roomId: string;
|
|
101
|
+
senderUUID?: any;
|
|
100
102
|
}
|
|
101
103
|
export interface ClientMessageBody {
|
|
102
104
|
interfaceName: 'ClientMessageBody';
|
|
103
105
|
shouldSendToSelf: boolean;
|
|
104
106
|
senderParticipant: Participant;
|
|
105
107
|
broadcastMessage: WebSocketMessageBody;
|
|
108
|
+
senderUUID?: any;
|
|
106
109
|
}
|
|
107
110
|
export interface RediSubsciptionDetail {
|
|
108
111
|
topic: string;
|
|
@@ -145,4 +148,5 @@ export declare class EachSocketConnectionHandler extends BaseSFUWebsocket {
|
|
|
145
148
|
private onRedisMessage;
|
|
146
149
|
private subscribeToRedisMessages;
|
|
147
150
|
private redisSubscribeToTopic;
|
|
151
|
+
private onLocalRedisMessage;
|
|
148
152
|
}
|
|
@@ -409,6 +409,7 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
409
409
|
}
|
|
410
410
|
this.redisSubscribtionDetails.forEach((eachRedisSubscribtionDetails) => {
|
|
411
411
|
RedisHandler_1.RedisHandler.getInstance().redisSubscriber.unsubscribe(eachRedisSubscribtionDetails.topic, eachRedisSubscribtionDetails.listener);
|
|
412
|
+
EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.off(eachRedisSubscribtionDetails.topic, this.onLocalRedisMessage);
|
|
412
413
|
});
|
|
413
414
|
this.redisSubscribtionDetails = [];
|
|
414
415
|
}
|
|
@@ -463,20 +464,33 @@ class EachSocketConnectionHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
463
464
|
// }
|
|
464
465
|
}
|
|
465
466
|
async subscribeToRedisMessages() {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
467
|
+
// EventEmitterHandler.getInstance().vaniEventEmitter.off(VaniEvent.OnLocalRedisMessage, this.onLocalRedisMessage)
|
|
468
|
+
// EventEmitterHandler.getInstance().vaniEventEmitter.on(VaniEvent.OnLocalRedisMessage, this.onLocalRedisMessage)
|
|
469
|
+
// RedisHandler.getInstance().redisSubscriber.on('message', (roomId, messageInString) => {
|
|
470
|
+
// const message = JSON.parse(messageInString);
|
|
471
|
+
// // console.debug(message)
|
|
472
|
+
// })
|
|
470
473
|
}
|
|
471
474
|
async redisSubscribeToTopic(topic) {
|
|
472
475
|
const isListenerAlreadyExist = this.redisSubscribtionDetails.find((eachRedisSubscribtionDetails) => eachRedisSubscribtionDetails.topic === topic);
|
|
473
476
|
if (!isListenerAlreadyExist) {
|
|
474
477
|
const listener = (data) => {
|
|
475
|
-
|
|
478
|
+
const parsedData = JSON.parse(data);
|
|
479
|
+
if (parsedData && parsedData.senderUUID && parsedData.senderUUID === ServerHandler_1.ServerHandler.getInstance().serverUUID) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
this.onRedisMessage(parsedData);
|
|
476
483
|
};
|
|
477
484
|
RedisHandler_1.RedisHandler.getInstance().redisSubscriber.subscribe(topic, listener);
|
|
485
|
+
EventEmitterHandler_1.EventEmitterHandler.getInstance().vaniEventEmitter.on(topic, this.onLocalRedisMessage);
|
|
478
486
|
this.redisSubscribtionDetails.push({ topic, listener });
|
|
479
487
|
}
|
|
480
488
|
}
|
|
489
|
+
onLocalRedisMessage = async (data) => {
|
|
490
|
+
const stringifiedData = data;
|
|
491
|
+
if (stringifiedData) {
|
|
492
|
+
this.onRedisMessage(JSON.parse(stringifiedData));
|
|
493
|
+
}
|
|
494
|
+
};
|
|
481
495
|
}
|
|
482
496
|
exports.EachSocketConnectionHandler = EachSocketConnectionHandler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vani-meeting-server",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.8",
|
|
4
4
|
"description": "Vani Meeting Server SDK",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"dotenv": "^16.0.2",
|
|
32
32
|
"express": "^4.18.1",
|
|
33
33
|
"helmet": "^6.0.0",
|
|
34
|
-
"mediasoup": "3.
|
|
34
|
+
"mediasoup": "3.19.13",
|
|
35
35
|
"public-ip": "4.0.3",
|
|
36
36
|
"typescript": "^5.6.2",
|
|
37
37
|
"uuid": "^9.0.0",
|
|
38
|
-
"ws": "^8.18.
|
|
38
|
+
"ws": "^8.18.3"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/uuid": "^8.3.4",
|