vani-meeting-server 2.8.7 → 2.8.9
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 +64 -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 +20 -5
- package/lib/websocket/WebSocketHandler.js +1 -1
- 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,33 @@ 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
|
+
const data = keyData.get(fieldOne);
|
|
135
|
+
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("CachedRedisResponse", data);
|
|
136
|
+
return data;
|
|
137
|
+
}
|
|
138
|
+
return undefined;
|
|
139
|
+
};
|
|
140
|
+
storeKeyValueForLocalCache = (key, fieldOne, fieldTwo) => {
|
|
141
|
+
let keyData = this.localCacheDataStorage.get(key);
|
|
142
|
+
if (!keyData) {
|
|
143
|
+
keyData = new Map();
|
|
144
|
+
this.localCacheDataStorage.set(key, keyData);
|
|
145
|
+
}
|
|
146
|
+
keyData.set(fieldOne, fieldTwo);
|
|
147
|
+
};
|
|
119
148
|
async setIpForRoomId(roomId, ipAddress) {
|
|
120
149
|
try {
|
|
121
150
|
const oldIps = await this.fetchIpsForRoomId(roomId);
|
|
@@ -125,9 +154,10 @@ class RedisHandler {
|
|
|
125
154
|
return;
|
|
126
155
|
}
|
|
127
156
|
oldIps.push({ ip: ipAddress, port: ServerHandler_1.ServerHandler.getInstance().serverStartRequest.port });
|
|
128
|
-
|
|
157
|
+
this.storeKeyValueForLocalCache(roomId, RedisKeyType.IpAddress, JSON.stringify(oldIps));
|
|
158
|
+
/*await*/ this.redisClient.hSet(roomId, RedisKeyType.IpAddress, JSON.stringify(oldIps));
|
|
129
159
|
this.updateRoomCleanupTimeOut(roomId);
|
|
130
|
-
await this.fetchIpsForRoomId(roomId)
|
|
160
|
+
// await this.fetchIpsForRoomId(roomId)
|
|
131
161
|
}
|
|
132
162
|
catch (err) {
|
|
133
163
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("setIpForRoomId", err);
|
|
@@ -138,7 +168,8 @@ class RedisHandler {
|
|
|
138
168
|
// this.fetchIpsForRoomId(roomId)
|
|
139
169
|
// }, 10000)
|
|
140
170
|
try {
|
|
141
|
-
const
|
|
171
|
+
const localCacheRedisData = this.getKeyValueForLocalCache(roomId, RedisKeyType.IpAddress);
|
|
172
|
+
const ipAddress = localCacheRedisData ? localCacheRedisData : await this.redisClient.hGet(roomId, RedisKeyType.IpAddress);
|
|
142
173
|
if (ipAddress) {
|
|
143
174
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("fetchIpsForRoomId", JSON.parse(ipAddress));
|
|
144
175
|
return JSON.parse(ipAddress);
|
|
@@ -157,7 +188,8 @@ class RedisHandler {
|
|
|
157
188
|
try {
|
|
158
189
|
const oldIps = await this.fetchIpsForRoomId(roomId);
|
|
159
190
|
const newIps = oldIps.filter((eachOldIp) => !(eachOldIp.ip === ipAddress && eachOldIp.port === ServerHandler_1.ServerHandler.getInstance().serverStartRequest.port));
|
|
160
|
-
|
|
191
|
+
this.storeKeyValueForLocalCache(roomId, RedisKeyType.IpAddress, JSON.stringify(newIps));
|
|
192
|
+
/*await*/ this.redisClient.hSet(roomId, RedisKeyType.IpAddress, JSON.stringify(newIps));
|
|
161
193
|
this.updateRoomCleanupTimeOut(roomId);
|
|
162
194
|
}
|
|
163
195
|
catch (err) {
|
|
@@ -169,6 +201,7 @@ class RedisHandler {
|
|
|
169
201
|
try {
|
|
170
202
|
const messages = await this.fetchMessagesForRoom(roomId);
|
|
171
203
|
messages.push(messagePayload);
|
|
204
|
+
// this.storeKeyValueForLocalCache(roomId, RedisKeyType.Messages, JSON.stringify(messages))
|
|
172
205
|
await this.redisClient.hSet(roomId, RedisKeyType.Messages, JSON.stringify(messages));
|
|
173
206
|
this.updateRoomCleanupTimeOut(roomId);
|
|
174
207
|
}
|
|
@@ -178,7 +211,8 @@ class RedisHandler {
|
|
|
178
211
|
}
|
|
179
212
|
async fetchMessagesForRoom(roomId) {
|
|
180
213
|
try {
|
|
181
|
-
const
|
|
214
|
+
// const localCacheMessages = this.getKeyValueForLocalCache(roomId, RedisKeyType.Messages)
|
|
215
|
+
const messages = /*localCacheMessages ? localCacheMessages : */ await this.redisClient.hGet(roomId, RedisKeyType.Messages);
|
|
182
216
|
if (messages) {
|
|
183
217
|
return JSON.parse(messages);
|
|
184
218
|
}
|
|
@@ -194,7 +228,8 @@ class RedisHandler {
|
|
|
194
228
|
//Meeting Time
|
|
195
229
|
async storeMeetingTimeForRoom(roomId, time) {
|
|
196
230
|
try {
|
|
197
|
-
|
|
231
|
+
this.storeKeyValueForLocalCache(roomId, RedisKeyType.MeetingTime, time ? time : new Date().getTime());
|
|
232
|
+
/*await*/ this.redisClient.hSet(roomId, RedisKeyType.MeetingTime, time ? time : new Date().getTime());
|
|
198
233
|
this.updateRoomCleanupTimeOut(roomId);
|
|
199
234
|
}
|
|
200
235
|
catch (err) {
|
|
@@ -204,7 +239,8 @@ class RedisHandler {
|
|
|
204
239
|
}
|
|
205
240
|
async fetchMeetingTimeForRoom(roomId) {
|
|
206
241
|
try {
|
|
207
|
-
const
|
|
242
|
+
const localCacheMessages = this.getKeyValueForLocalCache(roomId, RedisKeyType.MeetingTime);
|
|
243
|
+
const meetingTime = localCacheMessages ? localCacheMessages : await this.redisClient.hGet(roomId, RedisKeyType.MeetingTime);
|
|
208
244
|
if (meetingTime) {
|
|
209
245
|
return +meetingTime;
|
|
210
246
|
}
|
|
@@ -222,6 +258,7 @@ class RedisHandler {
|
|
|
222
258
|
try {
|
|
223
259
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("removeParticipantForRoom", participant);
|
|
224
260
|
const participantKey = RedisKeyType.Participants + ":" + participant.userId;
|
|
261
|
+
this.deleteKeyValueForLocalCache(roomId, participantKey);
|
|
225
262
|
await this.redisClient.hDel(roomId, participantKey);
|
|
226
263
|
// console.log("removeParticipantForRoom =====" , participantKey)
|
|
227
264
|
// console.log(await this.getAllParticipants(roomId))
|
|
@@ -240,7 +277,8 @@ class RedisHandler {
|
|
|
240
277
|
if (!participant.serverIpAddress) {
|
|
241
278
|
participant.serverIpAddress = await Constant_1.default.getPublicIp();
|
|
242
279
|
}
|
|
243
|
-
|
|
280
|
+
this.storeKeyValueForLocalCache(roomId, participantKey, JSON.stringify(participant));
|
|
281
|
+
/*await*/ this.redisClient.hSet(roomId, participantKey, JSON.stringify(participant));
|
|
244
282
|
// console.log("addUpdateParticipantForRoom =====" , participantKey)
|
|
245
283
|
// console.log(await this.getAllParticipants(roomId))
|
|
246
284
|
// console.log("addUpdateParticipantForRoom +++++")
|
|
@@ -254,7 +292,8 @@ class RedisHandler {
|
|
|
254
292
|
async getParticipantByUserId(roomId, userId) {
|
|
255
293
|
try {
|
|
256
294
|
const participantKey = RedisKeyType.Participants + ":" + userId;
|
|
257
|
-
const
|
|
295
|
+
const cahcedLocalData = this.getKeyValueForLocalCache(roomId, participantKey);
|
|
296
|
+
const particpantString = cahcedLocalData ? cahcedLocalData : await this.redisClient.hGet(roomId, participantKey);
|
|
258
297
|
if (particpantString) {
|
|
259
298
|
return JSON.parse(particpantString);
|
|
260
299
|
}
|
|
@@ -310,12 +349,26 @@ class RedisHandler {
|
|
|
310
349
|
catch (err) {
|
|
311
350
|
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("updateRoomCleanupTimeOut", err);
|
|
312
351
|
}
|
|
352
|
+
try {
|
|
353
|
+
this.cleanupLocalCache();
|
|
354
|
+
}
|
|
355
|
+
catch (e) {
|
|
356
|
+
}
|
|
313
357
|
}
|
|
314
358
|
releaseRedis = async () => {
|
|
315
359
|
RedisHandler.redisHandler = undefined;
|
|
316
360
|
this.redisClient.disconnect();
|
|
317
361
|
this.redisPublisher.disconnect();
|
|
318
362
|
this.redisSubscriber.disconnect();
|
|
363
|
+
this.cleanupLocalCache();
|
|
364
|
+
};
|
|
365
|
+
cleanupLocalCache = async () => {
|
|
366
|
+
try {
|
|
367
|
+
if (this.localCacheDataStorage && this.localCacheDataStorage.size > 1000) {
|
|
368
|
+
this.localCacheDataStorage = new Map();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
catch (err) { }
|
|
319
372
|
};
|
|
320
373
|
}
|
|
321
374
|
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,34 @@ 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
|
+
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("onLocalRedisMessage", stringifiedData);
|
|
493
|
+
this.onRedisMessage(JSON.parse(stringifiedData));
|
|
494
|
+
}
|
|
495
|
+
};
|
|
481
496
|
}
|
|
482
497
|
exports.EachSocketConnectionHandler = EachSocketConnectionHandler;
|
|
@@ -28,7 +28,7 @@ class WebSocketHandler {
|
|
|
28
28
|
connect() {
|
|
29
29
|
this.wss.on("connection", (socket, req) => {
|
|
30
30
|
this.lastKnownWebSocketStatusIsActive = true;
|
|
31
|
-
console.log("On New Connection", req.url)
|
|
31
|
+
// console.log("On New Connection", req.url)
|
|
32
32
|
if (req.url && req.url.includes("serverstatuscheck")) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vani-meeting-server",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.9",
|
|
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",
|