vani-meeting-server 2.9.4-beta5 → 2.9.5-beta1
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/index.js +10 -0
- package/lib/sfu/SFUEachRoomHandler.js +9 -4
- package/lib/sfu/SFUEachRoomMutliServerHandler.js +35 -15
- package/lib/sfu/SFUEachRoomUserHandler.js +24 -14
- package/lib/websocket/EachSocketConnectionHandler.d.ts +1 -0
- package/lib/websocket/EachSocketConnectionHandler.js +1 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -14,8 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const Utility_1 = require("./utility/Utility");
|
|
17
18
|
__exportStar(require("./models/Event"), exports);
|
|
18
19
|
__exportStar(require("./models/WebSocketServerStartRequest"), exports);
|
|
19
20
|
__exportStar(require("./models/Logs"), exports);
|
|
20
21
|
__exportStar(require("./ServerHandler"), exports);
|
|
21
22
|
__exportStar(require("./utility/EventEmitterHandler"), exports);
|
|
23
|
+
process.on('uncaughtException', (err) => {
|
|
24
|
+
console.warn('There was an uncaught error', err);
|
|
25
|
+
Utility_1.Utility.sendVaniError(err);
|
|
26
|
+
// By NOT calling process.exit(1), the pod stays running
|
|
27
|
+
});
|
|
28
|
+
process.on('unhandledRejection', (err) => {
|
|
29
|
+
// console.warn('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
30
|
+
Utility_1.Utility.sendVaniError(err);
|
|
31
|
+
});
|
|
@@ -352,11 +352,16 @@ class SFUEachRoomHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
async addAudioObserverForProducer(audioProducer) {
|
|
355
|
-
|
|
356
|
-
this.audioObserver
|
|
355
|
+
try {
|
|
356
|
+
if (this.audioObserver) {
|
|
357
|
+
this.audioObserver?.addProducer({ producerId: audioProducer.id });
|
|
358
|
+
}
|
|
359
|
+
if (this.audioLevelObserver) {
|
|
360
|
+
this.audioLevelObserver?.addProducer({ producerId: audioProducer.id });
|
|
361
|
+
}
|
|
357
362
|
}
|
|
358
|
-
|
|
359
|
-
|
|
363
|
+
catch (err) {
|
|
364
|
+
Utility_1.Utility.sendVaniError(err);
|
|
360
365
|
}
|
|
361
366
|
}
|
|
362
367
|
onUserLeft(participant) {
|
|
@@ -54,8 +54,13 @@ class SFUEachRoomMutliServerHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket
|
|
|
54
54
|
const pipeTransportAndPort = await this.createPipeTransport(message.data.ip);
|
|
55
55
|
if (pipeTransportAndPort && await Constant_1.default.getPublicIp() !== message.data.ip) {
|
|
56
56
|
if (!pipeTransportAndPort.transport.tuple.remoteIp) {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
try {
|
|
58
|
+
await pipeTransportAndPort.transport?.connect({ ip: message.data.ip, port: message.data.port });
|
|
59
|
+
this.redisBroadcastMessageToTopic(Utility_1.Utility.getTopicForRoomIdAndIp(message.roomId, message.data.ip), this.prepareMutilSystemEvents(EachSocketConnectionHandler_1.MultiSystemEvents.OnConnectPipe, message.roomId, { ip: await Constant_1.default.getPublicIp(), port: pipeTransportAndPort.port }));
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
Utility_1.Utility.sendVaniError(err);
|
|
63
|
+
}
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
}
|
|
@@ -63,11 +68,16 @@ class SFUEachRoomMutliServerHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket
|
|
|
63
68
|
const ip = message.data.ip;
|
|
64
69
|
if (this.pipeTransports[ip] && await Constant_1.default.getPublicIp() !== ip) {
|
|
65
70
|
if (!this.pipeTransports[ip].transport.tuple.remoteIp) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
try {
|
|
72
|
+
await this.pipeTransports[ip].transport.connect({ ip: ip, port: message.data.port });
|
|
73
|
+
this.redisBroadcastMessageToTopic(Utility_1.Utility.getTopicForRoomIdAndIp(message.roomId, message.data.ip), this.prepareMutilSystemEvents(EachSocketConnectionHandler_1.MultiSystemEvents.OnPipeConnected, message.roomId, { ip: await Constant_1.default.getPublicIp() }));
|
|
74
|
+
this.roomHandlerDataSource.getAllProducerForRoom().forEach(async (eachRoomProducer) => {
|
|
75
|
+
await this.consumeProductAndInfrom(this.pipeTransports[ip].transport, ip, eachRoomProducer);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
Utility_1.Utility.sendVaniError(err);
|
|
80
|
+
}
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
83
|
}
|
|
@@ -82,10 +92,15 @@ class SFUEachRoomMutliServerHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket
|
|
|
82
92
|
else if (message.type === EachSocketConnectionHandler_1.MultiSystemEvents.OnConsumerData) {
|
|
83
93
|
const ip = message.data.ip;
|
|
84
94
|
if (this.pipeTransports[ip] && await Constant_1.default.getPublicIp() !== ip) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
try {
|
|
96
|
+
const producer = await this.pipeTransports[ip].transport.produce({ rtpParameters: message.data.rtpParameters, kind: message.data.kind, appData: message.data.appData });
|
|
97
|
+
producer.appData.consumerId = message.data.consumerId;
|
|
98
|
+
this.onNewRemoteProducer(producer);
|
|
99
|
+
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("MultiSystemEvents.OnConsumerData", producer);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
Utility_1.Utility.sendVaniError(err);
|
|
103
|
+
}
|
|
89
104
|
}
|
|
90
105
|
}
|
|
91
106
|
else if (message.type === EachSocketConnectionHandler_1.MultiSystemEvents.OnRemoteConsumerClosed) {
|
|
@@ -171,10 +186,15 @@ class SFUEachRoomMutliServerHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket
|
|
|
171
186
|
// this.remoteProducers = this.remoteProducers.filter((eachRemoteProducer) => eachRemoteProducer.producer.id !== producer.id)
|
|
172
187
|
// }
|
|
173
188
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
189
|
+
try {
|
|
190
|
+
await this.roomHandlerDataSource.pipeToRoute(producer);
|
|
191
|
+
this.remoteProducers.push({ producer: producer, participant: remoteParticipant });
|
|
192
|
+
this.roomHandlerDataSource.onNewProducer(producer, remoteParticipant);
|
|
193
|
+
this.redisBroadcastMessageToTopic(Utility_1.Utility.getTopicForRoomIdAndIp(this.roomId, (await Constant_1.default.getPublicIp())), this.preapreClientMessageBody(false, remoteParticipant, this.preapreWebSocketMessageBody(EachSocketConnectionHandler_1.SFUMessageType.OnNewProducer, { producer: { id: producer.id, appData: producer.appData } })));
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
Utility_1.Utility.sendVaniError(err);
|
|
197
|
+
}
|
|
178
198
|
}
|
|
179
199
|
}
|
|
180
200
|
}
|
|
@@ -248,23 +248,33 @@ class SFUEachRoomUserHandler extends BaseSFUWebsocket_1.BaseSFUWebsocket {
|
|
|
248
248
|
}
|
|
249
249
|
};
|
|
250
250
|
async onTransportProduceSyncRequest(payload) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
251
|
+
try {
|
|
252
|
+
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log("onTransportProduceSyncRequest");
|
|
253
|
+
if (this.roomHandlerDataSource) {
|
|
254
|
+
const producer = await this.webrtcSendTransport?.produce(payload.message);
|
|
255
|
+
if (producer) {
|
|
256
|
+
this.addObserverForProducer(producer);
|
|
257
|
+
await this.onNewProducer(producer);
|
|
258
|
+
if (producer.kind === 'audio') {
|
|
259
|
+
try {
|
|
260
|
+
this.roomHandlerDataSource.addAudioObserverForProducer(producer);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
Utility_1.Utility.sendVaniError(err);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
this.redisBroadcastMessageToTopic(this.selfParticipant.userId, this.preapreClientMessageBody(true, this.selfParticipant, this.preapreWebSocketMessageBody(EachSocketConnectionHandler_1.SFUMessageType.OnProduceSyncDone, { transportId: this.webrtcSendTransport?.id, producerId: producer.id, appData: producer.appData })));
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
const errorPayload = { message: "Not able to create Producer - onTransportProduceSyncRequest - SFUEachRoomUserHandler", extraData: payload };
|
|
270
|
+
Utility_1.Utility.checkAndSendLogs({ logLevel: WebSocketServerStartRequest_1.LogLevel.Error, roomId: this.selfParticipant.roomId, payload: errorPayload, logType: Logs_1.LogType.LogTypeError });
|
|
271
|
+
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log(" Error in creating producer ", payload);
|
|
259
272
|
}
|
|
260
|
-
this.redisBroadcastMessageToTopic(this.selfParticipant.userId, this.preapreClientMessageBody(true, this.selfParticipant, this.preapreWebSocketMessageBody(EachSocketConnectionHandler_1.SFUMessageType.OnProduceSyncDone, { transportId: this.webrtcSendTransport?.id, producerId: producer.id, appData: producer.appData })));
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
const errorPayload = { message: "Not able to create Producer - onTransportProduceSyncRequest - SFUEachRoomUserHandler", extraData: payload };
|
|
264
|
-
Utility_1.Utility.checkAndSendLogs({ logLevel: WebSocketServerStartRequest_1.LogLevel.Error, roomId: this.selfParticipant.roomId, payload: errorPayload, logType: Logs_1.LogType.LogTypeError });
|
|
265
|
-
ServerHandler_1.ServerHandler.getInstance().serverStartRequest && ServerHandler_1.ServerHandler.getInstance().serverStartRequest.logLevel !== WebSocketServerStartRequest_1.LogLevel.None && console.log(" Error in creating producer ", payload);
|
|
266
273
|
}
|
|
267
274
|
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
Utility_1.Utility.sendVaniError(err);
|
|
277
|
+
}
|
|
268
278
|
}
|
|
269
279
|
async onResumeProducer(payload) {
|
|
270
280
|
const producerId = payload.message.producerId;
|
|
@@ -98,6 +98,7 @@ var WebrtcMessageType;
|
|
|
98
98
|
(function (WebrtcMessageType) {
|
|
99
99
|
WebrtcMessageType["WebrtcMessage"] = "WebrtcMessage";
|
|
100
100
|
WebrtcMessageType["SendOffer"] = "SendOffer";
|
|
101
|
+
WebrtcMessageType["IceCandidate"] = "IceCandidate";
|
|
101
102
|
WebrtcMessageType["SendAnswer"] = "SendAnswer";
|
|
102
103
|
})(WebrtcMessageType || (exports.WebrtcMessageType = WebrtcMessageType = {}));
|
|
103
104
|
var MultiSystemEvents;
|