vani-meeting-client-native 0.2.1 → 0.2.3
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/MeetingHandler.d.ts +3 -0
- package/lib/MeetingHandler.js +34 -1
- package/lib/base/Base.d.ts +1 -0
- package/lib/base/Base.js +4 -0
- package/lib/inter-communication-handler/CommunicationHandler.js +10 -3
- package/lib/model/Participant.d.ts +2 -0
- package/lib/model/Participant.js +1 -0
- package/lib/model/PeerConnection.d.ts +6 -0
- package/lib/model/PeerConnection.js +6 -0
- package/lib/user-media-handler/UserMediaHandler.js +1 -4
- package/lib/utility/DynamicLibHelper.d.ts +1 -0
- package/lib/utility/DynamicLibHelper.js +11 -0
- package/lib/utility/DynamicLibHelper.native.d.ts +1 -0
- package/lib/utility/DynamicLibHelper.native.js +11 -0
- package/lib/utility/DynamicLibHelper.node.d.ts +1 -0
- package/lib/utility/DynamicLibHelper.node.js +3 -0
- package/lib/video-call-handler/BaseVideoCallHandler.d.ts +4 -0
- package/lib/video-call-handler/BaseVideoCallHandler.js +21 -0
- package/lib/video-call-handler/SFUHandler.js +1 -1
- package/lib/video-call-handler/WebrtcHandler.d.ts +5 -0
- package/lib/video-call-handler/WebrtcHandler.js +54 -1
- package/lib/websocket-handler/WebsocketHandler.d.ts +9 -2
- package/lib/websocket-handler/WebsocketHandler.js +67 -21
- package/package.json +1 -1
package/lib/MeetingHandler.d.ts
CHANGED
|
@@ -14,7 +14,10 @@ export declare class MeetingHandler {
|
|
|
14
14
|
private userMediaHandler?;
|
|
15
15
|
meetingStartRequestObject(roomId: string, userId: string, appId: string, wssUrl: string, shouldIgnoreCaseForRoomId?: boolean): MeetingStartRequest;
|
|
16
16
|
endAndDestory(): void;
|
|
17
|
+
cleanupWebsocket: () => void;
|
|
18
|
+
isWebSocketInPreConnect: () => void;
|
|
17
19
|
requestToCloseTheRoom: () => void;
|
|
20
|
+
preconnect: (url: string) => Promise<void>;
|
|
18
21
|
init(): Promise<boolean>;
|
|
19
22
|
recreateVideoCallHandler: () => Promise<BaseVideoCallHandler>;
|
|
20
23
|
switchCamera(): void;
|
package/lib/MeetingHandler.js
CHANGED
|
@@ -46,10 +46,34 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
46
46
|
function MeetingHandler() {
|
|
47
47
|
var _this = this;
|
|
48
48
|
this.communicationHandler = new CommunicationHandler(this);
|
|
49
|
+
this.cleanupWebsocket = function () {
|
|
50
|
+
var _a;
|
|
51
|
+
try {
|
|
52
|
+
(_a = _this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
53
|
+
_this.websocketCallHandler = undefined;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
this.isWebSocketInPreConnect = function () {
|
|
59
|
+
var _a;
|
|
60
|
+
if (_this.websocketCallHandler) {
|
|
61
|
+
(_a = _this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.isWebSocketInPreConnect();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
49
64
|
this.requestToCloseTheRoom = function () {
|
|
50
65
|
var _a;
|
|
51
66
|
(_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.requestToCloseTheRoom();
|
|
52
67
|
};
|
|
68
|
+
this.preconnect = function (url) { return __awaiter(_this, void 0, void 0, function () {
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
if (!this.websocketCallHandler) {
|
|
71
|
+
this.websocketCallHandler = new WebsocketHandler(this.meetingStartRequest, this.communicationHandler);
|
|
72
|
+
}
|
|
73
|
+
this.websocketCallHandler.startSocketConnection(true, url);
|
|
74
|
+
return [2 /*return*/];
|
|
75
|
+
});
|
|
76
|
+
}); };
|
|
53
77
|
this.recreateVideoCallHandler = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
54
78
|
var _a;
|
|
55
79
|
var _b;
|
|
@@ -140,11 +164,19 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
140
164
|
return [4 /*yield*/, new DynamicLibHelper().getVideoCallClassHandler((_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.meetingType, this.meetingStartRequest, this.communicationHandler)];
|
|
141
165
|
case 3:
|
|
142
166
|
_e.videoCallHandler = _f.sent();
|
|
143
|
-
|
|
167
|
+
return [3 /*break*/, 5];
|
|
144
168
|
case 4:
|
|
169
|
+
if (this.meetingStartRequest) {
|
|
170
|
+
this.videoCallHandler.setMeetingRequest(this.meetingStartRequest);
|
|
171
|
+
}
|
|
172
|
+
_f.label = 5;
|
|
173
|
+
case 5:
|
|
145
174
|
if (!this.websocketCallHandler) {
|
|
146
175
|
this.websocketCallHandler = new WebsocketHandler(this.meetingStartRequest, this.communicationHandler);
|
|
147
176
|
}
|
|
177
|
+
else if (this.meetingStartRequest) {
|
|
178
|
+
this.websocketCallHandler.setMeetingRequest(this.meetingStartRequest);
|
|
179
|
+
}
|
|
148
180
|
// this.handleGA();
|
|
149
181
|
this.emitMessageToSource(VaniEvent.OnInitDone, {});
|
|
150
182
|
return [2 /*return*/, true];
|
|
@@ -450,6 +482,7 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
450
482
|
MeetingHandler.prototype.checkSocket = function () {
|
|
451
483
|
return __awaiter(this, void 0, void 0, function () {
|
|
452
484
|
return __generator(this, function (_a) {
|
|
485
|
+
debugger;
|
|
453
486
|
if (!this.meetingStartRequest) {
|
|
454
487
|
log.error("meetingStartRequestObject not found");
|
|
455
488
|
return [2 /*return*/, false];
|
package/lib/base/Base.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare abstract class Base {
|
|
|
4
4
|
protected meetingStartRequest?: MeetingStartRequest;
|
|
5
5
|
protected communicationHandler?: CommunicationHandler;
|
|
6
6
|
constructor(_meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler);
|
|
7
|
+
setMeetingRequest: (_meetingStartRequest: MeetingStartRequest) => void;
|
|
7
8
|
protected onObjectCreated(): void;
|
|
8
9
|
cleanup(): void;
|
|
9
10
|
}
|
package/lib/base/Base.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
var Base = /** @class */ (function () {
|
|
2
2
|
function Base(_meetingStartRequest, _communicationHandler) {
|
|
3
|
+
var _this = this;
|
|
4
|
+
this.setMeetingRequest = function (_meetingStartRequest) {
|
|
5
|
+
_this.meetingStartRequest = _meetingStartRequest;
|
|
6
|
+
};
|
|
3
7
|
this.meetingStartRequest = _meetingStartRequest;
|
|
4
8
|
this.communicationHandler = _communicationHandler;
|
|
5
9
|
this.onObjectCreated();
|
|
@@ -230,6 +230,7 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
230
230
|
};
|
|
231
231
|
CommunicationHandler.prototype.onServerParticipants = function (data) {
|
|
232
232
|
var _this = this;
|
|
233
|
+
var _a;
|
|
233
234
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info(data);
|
|
234
235
|
if (data && data.message) {
|
|
235
236
|
var userIds = "";
|
|
@@ -243,6 +244,7 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
243
244
|
// allParticiapntsToBeRemove.forEach(participant => {
|
|
244
245
|
// this.removeParticipant(participant, true);
|
|
245
246
|
// })
|
|
247
|
+
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onAllParticipants(this.allParticipants);
|
|
246
248
|
this.emitMessageToSource(VaniEvent.OnAllParticipants, this.allParticipants);
|
|
247
249
|
}
|
|
248
250
|
};
|
|
@@ -253,7 +255,7 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
253
255
|
return this.allParticipants.find(function (participant) { return participant.userId === userId; });
|
|
254
256
|
};
|
|
255
257
|
CommunicationHandler.prototype.addParticipantIfNotExist = function (participant, shouldInfrom) {
|
|
256
|
-
var _a, _b, _c;
|
|
258
|
+
var _a, _b, _c, _d;
|
|
257
259
|
if (shouldInfrom === void 0) { shouldInfrom = false; }
|
|
258
260
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("addParticipantIfNotExist", this.allParticipants);
|
|
259
261
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("addParticipantIfNotExist new user", participant);
|
|
@@ -287,16 +289,17 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
287
289
|
catch (err) {
|
|
288
290
|
}
|
|
289
291
|
this.allParticipants.push(participant);
|
|
292
|
+
(_c = this.videoCallHandler) === null || _c === void 0 ? void 0 : _c.onUserJoined(participant);
|
|
290
293
|
if (shouldInfrom) {
|
|
291
294
|
this.emitMessageToSource(VaniEvent.OnUserJoined, participant);
|
|
292
295
|
}
|
|
293
|
-
(
|
|
296
|
+
(_d = this.videoCallHandler) === null || _d === void 0 ? void 0 : _d.onParticipantUpdated();
|
|
294
297
|
return participant;
|
|
295
298
|
}
|
|
296
299
|
};
|
|
297
300
|
CommunicationHandler.prototype.removeParticipant = function (participant, shouldInfrom) {
|
|
298
301
|
var _this = this;
|
|
299
|
-
var _a;
|
|
302
|
+
var _a, _b;
|
|
300
303
|
if (shouldInfrom === void 0) { shouldInfrom = false; }
|
|
301
304
|
var tracks = this.getAllTracksForParticipant(participant);
|
|
302
305
|
if (tracks) {
|
|
@@ -306,6 +309,7 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
306
309
|
}
|
|
307
310
|
Utility.deleteArrayObject(participant, this.allParticipants);
|
|
308
311
|
(_a = this.videoCallHandler) === null || _a === void 0 ? void 0 : _a.onParticipantUpdated();
|
|
312
|
+
(_b = this.videoCallHandler) === null || _b === void 0 ? void 0 : _b.onUserLeft(participant);
|
|
309
313
|
if (shouldInfrom) {
|
|
310
314
|
this.emitMessageToSource(VaniEvent.OnUserLeft, participant);
|
|
311
315
|
}
|
|
@@ -471,6 +475,9 @@ var CommunicationHandler = /** @class */ (function () {
|
|
|
471
475
|
var _a;
|
|
472
476
|
(_a = this.websocketCallHandler) === null || _a === void 0 ? void 0 : _a.sendSocketMessage(type, data);
|
|
473
477
|
};
|
|
478
|
+
// public sendWebSocketMessageForWebrtc(type: WebrtcMessageType, data: any, to : string) {
|
|
479
|
+
// this.websocketCallHandler?.sendSocketMessage(type, data)
|
|
480
|
+
// }
|
|
474
481
|
CommunicationHandler.prototype.onVideoCallWebSocketMessage = function (websocketMessage) {
|
|
475
482
|
var _a;
|
|
476
483
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PeerConnection } from "./PeerConnection";
|
|
1
2
|
export declare class Participant {
|
|
2
3
|
userId: string;
|
|
3
4
|
userData: any;
|
|
@@ -12,5 +13,6 @@ export declare class Participant {
|
|
|
12
13
|
isAudioEnable: boolean;
|
|
13
14
|
isStartMeetingCalled: boolean;
|
|
14
15
|
isRecordingUser: boolean;
|
|
16
|
+
peerConnections: Map<string, PeerConnection>;
|
|
15
17
|
constructor(_userId: string, _roomId: string, _userData?: any, _isAdmin?: boolean);
|
|
16
18
|
}
|
package/lib/model/Participant.js
CHANGED
|
@@ -12,6 +12,7 @@ var Participant = /** @class */ (function () {
|
|
|
12
12
|
this.isAudioEnable = false;
|
|
13
13
|
this.isStartMeetingCalled = false;
|
|
14
14
|
this.isRecordingUser = false;
|
|
15
|
+
this.peerConnections = new Map();
|
|
15
16
|
this.userId = _userId;
|
|
16
17
|
this.roomId = _roomId;
|
|
17
18
|
this.userData = _userData;
|
|
@@ -258,10 +258,7 @@ var UserMediaHandler = /** @class */ (function (_super) {
|
|
|
258
258
|
};
|
|
259
259
|
UserMediaHandler.prototype.getAudioDictionay = function () {
|
|
260
260
|
var permissionDict = {
|
|
261
|
-
echoCancellation: true, noiseSuppression: true, autoGainControl: true
|
|
262
|
-
googNoiseSuppression: true,
|
|
263
|
-
googEchoCancellation: true,
|
|
264
|
-
googHighpassFilter: true
|
|
261
|
+
echoCancellation: true, noiseSuppression: true, autoGainControl: true
|
|
265
262
|
};
|
|
266
263
|
return permissionDict;
|
|
267
264
|
};
|
|
@@ -5,4 +5,5 @@ export declare class DynamicLibHelper {
|
|
|
5
5
|
getVideoCallClassHandler(meetingType: MeetingType, meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler): Promise<import("../video-call-handler/SFUHandler").SFUHandler | import("../video-call-handler/WebrtcHandler").WebrtcHandler>;
|
|
6
6
|
getMediaDevicesVariable(meetingStartRequest: MeetingStartRequest): any;
|
|
7
7
|
getMediaStreamVariable(meetingStartRequest: MeetingStartRequest): any;
|
|
8
|
+
getRTCPeerConnection(meetingStartRequest: MeetingStartRequest): any;
|
|
8
9
|
}
|
|
@@ -102,6 +102,17 @@ var DynamicLibHelper = /** @class */ (function () {
|
|
|
102
102
|
}
|
|
103
103
|
return MediaStream;
|
|
104
104
|
};
|
|
105
|
+
DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
|
|
106
|
+
try {
|
|
107
|
+
if (meetingStartRequest === null || meetingStartRequest === void 0 ? void 0 : meetingStartRequest.isMobileApp) {
|
|
108
|
+
return new (require("react-native-webrtc").RTCPeerConnection)();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
log.error("react-native-webrtc not found. Please do npm install ");
|
|
113
|
+
}
|
|
114
|
+
return new RTCPeerConnection();
|
|
115
|
+
};
|
|
105
116
|
return DynamicLibHelper;
|
|
106
117
|
}());
|
|
107
118
|
export { DynamicLibHelper };
|
|
@@ -5,4 +5,5 @@ export declare class DynamicLibHelper {
|
|
|
5
5
|
getVideoCallClassHandler(meetingType: MeetingType, meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler): Promise<import("../video-call-handler/SFUHandler").SFUHandler | import("../video-call-handler/WebrtcHandler").WebrtcHandler>;
|
|
6
6
|
getMediaDevicesVariable(meetingStartRequest: MeetingStartRequest): any;
|
|
7
7
|
getMediaStreamVariable(meetingStartRequest: MeetingStartRequest): any;
|
|
8
|
+
getRTCPeerConnection(meetingStartRequest: MeetingStartRequest): any;
|
|
8
9
|
}
|
|
@@ -102,6 +102,17 @@ var DynamicLibHelper = /** @class */ (function () {
|
|
|
102
102
|
}
|
|
103
103
|
return MediaStream;
|
|
104
104
|
};
|
|
105
|
+
DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
|
|
106
|
+
try {
|
|
107
|
+
if (meetingStartRequest === null || meetingStartRequest === void 0 ? void 0 : meetingStartRequest.isMobileApp) {
|
|
108
|
+
return new (require("react-native-webrtc").RTCPeerConnection)();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
log.error("react-native-webrtc not found. Please do npm install ");
|
|
113
|
+
}
|
|
114
|
+
return new RTCPeerConnection();
|
|
115
|
+
};
|
|
105
116
|
return DynamicLibHelper;
|
|
106
117
|
}());
|
|
107
118
|
export { DynamicLibHelper };
|
|
@@ -5,4 +5,5 @@ export declare class DynamicLibHelper {
|
|
|
5
5
|
getVideoCallClassHandler(meetingType: MeetingType, meetingStartRequest: MeetingStartRequest, _communicationHandler: CommunicationHandler): Promise<import("../video-call-handler/SFUHandler").SFUHandler | import("../video-call-handler/WebrtcHandler").WebrtcHandler>;
|
|
6
6
|
getMediaDevicesVariable(meetingStartRequest: MeetingStartRequest): any;
|
|
7
7
|
getMediaStreamVariable(meetingStartRequest: MeetingStartRequest): any;
|
|
8
|
+
getRTCPeerConnection(meetingStartRequest: MeetingStartRequest): any;
|
|
8
9
|
}
|
|
@@ -103,6 +103,9 @@ var DynamicLibHelper = /** @class */ (function () {
|
|
|
103
103
|
}
|
|
104
104
|
return MediaStream;
|
|
105
105
|
};
|
|
106
|
+
DynamicLibHelper.prototype.getRTCPeerConnection = function (meetingStartRequest) {
|
|
107
|
+
return new RTCPeerConnection();
|
|
108
|
+
};
|
|
106
109
|
return DynamicLibHelper;
|
|
107
110
|
}());
|
|
108
111
|
export { DynamicLibHelper };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Track } from "../model/Track";
|
|
2
2
|
import { WebSocketMessageBody } from "../websocket-handler/WebsocketHandler";
|
|
3
|
+
import { Participant } from "../model/Participant";
|
|
3
4
|
import { Base } from "../base/Base";
|
|
4
5
|
import { TrackStats } from "../model/TrackStats";
|
|
5
6
|
export declare abstract class BaseVideoCallHandler extends Base {
|
|
@@ -16,6 +17,9 @@ export declare abstract class BaseVideoCallHandler extends Base {
|
|
|
16
17
|
abstract onParticipantUpdated(): void;
|
|
17
18
|
abstract createDataChannel(): any;
|
|
18
19
|
abstract sendMessageViaDataChannel(messagePayload: any): any;
|
|
20
|
+
onAllParticipants(participants: Participant[]): Promise<void>;
|
|
21
|
+
onUserJoined(participants: Participant): Promise<void>;
|
|
22
|
+
onUserLeft(participants: Participant): Promise<void>;
|
|
19
23
|
getConsumerForTrack(track: Track): void;
|
|
20
24
|
resumeProducerOrConsumerForTrack(track: Track): Promise<void>;
|
|
21
25
|
pauseProducerOrConsumerForTrack(track: Track): Promise<void>;
|
|
@@ -68,6 +68,27 @@ var BaseVideoCallHandler = /** @class */ (function (_super) {
|
|
|
68
68
|
_super.prototype.onObjectCreated.call(this);
|
|
69
69
|
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.setVideoCallHandler(this);
|
|
70
70
|
};
|
|
71
|
+
BaseVideoCallHandler.prototype.onAllParticipants = function (participants) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
return [2 /*return*/];
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
BaseVideoCallHandler.prototype.onUserJoined = function (participants) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
BaseVideoCallHandler.prototype.onUserLeft = function (participants) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
71
92
|
BaseVideoCallHandler.prototype.getConsumerForTrack = function (track) {
|
|
72
93
|
};
|
|
73
94
|
BaseVideoCallHandler.prototype.resumeProducerOrConsumerForTrack = function (track) {
|
|
@@ -430,7 +430,7 @@ var SFUHandler = /** @class */ (function (_super) {
|
|
|
430
430
|
producerData.encodings = this.meetingStartRequest.simulcastEncodings;
|
|
431
431
|
}
|
|
432
432
|
if (track.track.kind === "audio") {
|
|
433
|
-
producerData.codecOptions = { opusStereo: true, opusFec: true };
|
|
433
|
+
producerData.codecOptions = { opusStereo: true, opusFec: true, opusDtx: true };
|
|
434
434
|
if (this.meetingStartRequest.maxAudioBitrateConfig > 0) {
|
|
435
435
|
producerData.codecOptions.opusMaxAverageBitrate = (_d = this.meetingStartRequest) === null || _d === void 0 ? void 0 : _d.maxAudioBitrateConfig;
|
|
436
436
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { Participant } from "../model/Participant";
|
|
1
2
|
import { Track } from "../model/Track";
|
|
2
3
|
import { WebSocketMessageBody } from "../websocket-handler/WebsocketHandler";
|
|
3
4
|
import { BaseVideoCallHandler } from "./BaseVideoCallHandler";
|
|
4
5
|
export declare class WebrtcHandler extends BaseVideoCallHandler {
|
|
6
|
+
private dynamicLibHelper;
|
|
5
7
|
onParticipantUpdated(): void;
|
|
6
8
|
resumeIncomingTrack(track: Track): void;
|
|
7
9
|
pauseIncomingTrack(track: Track): void;
|
|
8
10
|
onSocketMessage(websocketCallHandler: WebSocketMessageBody): void;
|
|
11
|
+
onAllParticipants(participants: Participant[]): Promise<void>;
|
|
12
|
+
onUserJoined(participant: Participant): Promise<void>;
|
|
9
13
|
init(): Promise<void>;
|
|
10
14
|
onReconnect(): Promise<void>;
|
|
11
15
|
stopTrack(track: Track): void;
|
|
@@ -14,4 +18,5 @@ export declare class WebrtcHandler extends BaseVideoCallHandler {
|
|
|
14
18
|
sendTrack(track: Track): void;
|
|
15
19
|
createDataChannel(): Promise<void>;
|
|
16
20
|
sendMessageViaDataChannel(messagePayload: any): void;
|
|
21
|
+
private isOfferInitParticipant;
|
|
17
22
|
}
|
|
@@ -52,10 +52,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
52
52
|
import { BaseVideoCallHandler } from "./BaseVideoCallHandler";
|
|
53
53
|
import log from 'loglevel';
|
|
54
54
|
import { LogLevel } from "../model/MeetingStartRequest";
|
|
55
|
+
import { DynamicLibHelper } from "../utility/DynamicLibHelper";
|
|
56
|
+
import { PeerConnection } from "../model/PeerConnection";
|
|
55
57
|
var WebrtcHandler = /** @class */ (function (_super) {
|
|
56
58
|
__extends(WebrtcHandler, _super);
|
|
57
59
|
function WebrtcHandler() {
|
|
58
|
-
|
|
60
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
61
|
+
_this.dynamicLibHelper = (new DynamicLibHelper());
|
|
62
|
+
_this.isOfferInitParticipant = function (participant) {
|
|
63
|
+
var selfParticpant = _this.communicationHandler.getSelfParticipant();
|
|
64
|
+
if (participant.userId > selfParticpant.userId) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
};
|
|
69
|
+
return _this;
|
|
59
70
|
}
|
|
60
71
|
WebrtcHandler.prototype.onParticipantUpdated = function () {
|
|
61
72
|
throw new Error("Method not implemented.");
|
|
@@ -69,6 +80,48 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
69
80
|
WebrtcHandler.prototype.onSocketMessage = function (websocketCallHandler) {
|
|
70
81
|
throw new Error("Method not implemented.");
|
|
71
82
|
};
|
|
83
|
+
WebrtcHandler.prototype.onAllParticipants = function (participants) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var _this = this;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
participants.forEach(function (eachParticiapant) {
|
|
88
|
+
_this.onUserJoined(eachParticiapant);
|
|
89
|
+
});
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
WebrtcHandler.prototype.onUserJoined = function (participant) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var selfParticpant, isOfferInitParticipant, peerConnectionObject, peerConnection, offer;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
101
|
+
if (!(selfParticpant.userId !== participant.userId && !selfParticpant.peerConnections.has(participant.userId))) return [3 /*break*/, 2];
|
|
102
|
+
isOfferInitParticipant = this.isOfferInitParticipant(participant);
|
|
103
|
+
if (!!isOfferInitParticipant) return [3 /*break*/, 2];
|
|
104
|
+
if (!selfParticpant.peerConnections.has(participant.userId)) {
|
|
105
|
+
selfParticpant.peerConnections.set(participant.userId, new PeerConnection());
|
|
106
|
+
}
|
|
107
|
+
peerConnectionObject = selfParticpant.peerConnections.get(participant.userId);
|
|
108
|
+
peerConnection = this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
109
|
+
if (!peerConnection) return [3 /*break*/, 2];
|
|
110
|
+
peerConnection.addTransceiver("audio", { direction: "sendrecv" });
|
|
111
|
+
peerConnection.addTransceiver("video", { direction: "sendrecv" });
|
|
112
|
+
return [4 /*yield*/, peerConnection.createOffer()];
|
|
113
|
+
case 1:
|
|
114
|
+
offer = _a.sent();
|
|
115
|
+
peerConnection.setLocalDescription(offer);
|
|
116
|
+
peerConnectionObject.offer = offer;
|
|
117
|
+
// send offer to peer
|
|
118
|
+
console.log("offer", offer);
|
|
119
|
+
_a.label = 2;
|
|
120
|
+
case 2: return [2 /*return*/];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
72
125
|
WebrtcHandler.prototype.init = function () {
|
|
73
126
|
return __awaiter(this, void 0, void 0, function () {
|
|
74
127
|
return __generator(this, function (_a) {
|
|
@@ -30,6 +30,10 @@ export declare enum WebSocketBasicEvents {
|
|
|
30
30
|
OnChat = "chat",
|
|
31
31
|
SelfLeft = "selfLeft"
|
|
32
32
|
}
|
|
33
|
+
export declare enum WebrtcMessageType {
|
|
34
|
+
SendOffer = "SendOffer",
|
|
35
|
+
SendAnswer = "SendAnswer"
|
|
36
|
+
}
|
|
33
37
|
export declare enum SFUMessageType {
|
|
34
38
|
SFUMessage = "sfuMessage",
|
|
35
39
|
GetRouterRtpCapabilities = "routerRtpCapabilities",
|
|
@@ -70,12 +74,13 @@ export declare enum SFUMessageType {
|
|
|
70
74
|
OnProducerScoreChange = "OnProducerScoreChange",
|
|
71
75
|
OnConsumerLayerChange = "OnConsumerLayerChange"
|
|
72
76
|
}
|
|
73
|
-
export type WebSocketEvents = SFUMessageType | WebSocketBasicEvents;
|
|
77
|
+
export type WebSocketEvents = SFUMessageType | WebSocketBasicEvents | WebrtcMessageType;
|
|
74
78
|
export interface WebSocketMessageBody {
|
|
75
79
|
type?: WebSocketEvents;
|
|
76
80
|
data?: any;
|
|
77
81
|
}
|
|
78
82
|
export declare class WebsocketHandler extends Base {
|
|
83
|
+
private websocketConnectionUrl?;
|
|
79
84
|
private loadBalancerIpAddressForWebSocket?;
|
|
80
85
|
private isEnded;
|
|
81
86
|
private isWebSocketConnectionInProgress;
|
|
@@ -89,8 +94,10 @@ export declare class WebsocketHandler extends Base {
|
|
|
89
94
|
private lastPingTimeStamp;
|
|
90
95
|
protected onObjectCreated(): void;
|
|
91
96
|
cleanup(): Promise<void>;
|
|
92
|
-
startSocketConnection(): Promise<void>;
|
|
97
|
+
startSocketConnection(isForPreConnect?: boolean, url?: string): Promise<void>;
|
|
93
98
|
private connect;
|
|
99
|
+
isWebSocketInPreConnect(): boolean;
|
|
100
|
+
isWebScoketConnectedWithoutSetup(): boolean;
|
|
94
101
|
isWebScoketConnected(): boolean;
|
|
95
102
|
sendSocketMessage(type: WebSocketEvents, data: any): void;
|
|
96
103
|
reconnectOnInternetFailur(): void;
|
|
@@ -85,6 +85,11 @@ export var WebSocketBasicEvents;
|
|
|
85
85
|
WebSocketBasicEvents["OnChat"] = "chat";
|
|
86
86
|
WebSocketBasicEvents["SelfLeft"] = "selfLeft";
|
|
87
87
|
})(WebSocketBasicEvents || (WebSocketBasicEvents = {}));
|
|
88
|
+
export var WebrtcMessageType;
|
|
89
|
+
(function (WebrtcMessageType) {
|
|
90
|
+
WebrtcMessageType["SendOffer"] = "SendOffer";
|
|
91
|
+
WebrtcMessageType["SendAnswer"] = "SendAnswer";
|
|
92
|
+
})(WebrtcMessageType || (WebrtcMessageType = {}));
|
|
88
93
|
export var SFUMessageType;
|
|
89
94
|
(function (SFUMessageType) {
|
|
90
95
|
SFUMessageType["SFUMessage"] = "sfuMessage";
|
|
@@ -192,16 +197,16 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
192
197
|
});
|
|
193
198
|
});
|
|
194
199
|
};
|
|
195
|
-
WebsocketHandler.prototype.startSocketConnection = function () {
|
|
200
|
+
WebsocketHandler.prototype.startSocketConnection = function (isForPreConnect, url) {
|
|
196
201
|
return __awaiter(this, void 0, void 0, function () {
|
|
197
202
|
var request, urlToGetIpAddress, config;
|
|
198
203
|
var _this = this;
|
|
199
204
|
return __generator(this, function (_a) {
|
|
200
|
-
if (!this.meetingStartRequest) {
|
|
205
|
+
if (!this.meetingStartRequest && !isForPreConnect) {
|
|
201
206
|
log.log("meetingStartRequest not found on startSocketConnection");
|
|
202
207
|
return [2 /*return*/];
|
|
203
208
|
}
|
|
204
|
-
if (this.meetingStartRequest.dynamicWebSocketFetchBaseUrl) {
|
|
209
|
+
if (!isForPreConnect && this.meetingStartRequest.dynamicWebSocketFetchBaseUrl) {
|
|
205
210
|
if (this.meetingStartRequest.dynamicWebSocketFetchBaseUrl.endsWith("/") === false) {
|
|
206
211
|
this.meetingStartRequest.dynamicWebSocketFetchBaseUrl = this.meetingStartRequest.dynamicWebSocketFetchBaseUrl + "/";
|
|
207
212
|
}
|
|
@@ -229,46 +234,68 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
229
234
|
});
|
|
230
235
|
}
|
|
231
236
|
else {
|
|
232
|
-
this.connect(false);
|
|
237
|
+
this.connect(false, isForPreConnect, url);
|
|
233
238
|
}
|
|
234
239
|
return [2 /*return*/];
|
|
235
240
|
});
|
|
236
241
|
});
|
|
237
242
|
};
|
|
238
|
-
WebsocketHandler.prototype.connect = function (isForceFully) {
|
|
243
|
+
WebsocketHandler.prototype.connect = function (isForceFully, isForPreConnect, _url) {
|
|
239
244
|
var _a, _b, _c;
|
|
240
245
|
if (isForceFully === void 0) { isForceFully = false; }
|
|
241
246
|
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
-
var
|
|
247
|
+
var url_1;
|
|
243
248
|
var _this = this;
|
|
244
249
|
return __generator(this, function (_d) {
|
|
245
250
|
if (this.isEnded === true || this.isWebSocketConnectionInProgress) {
|
|
246
251
|
return [2 /*return*/];
|
|
247
252
|
}
|
|
248
|
-
if (!this.wss || (isForceFully && this.
|
|
249
|
-
|
|
250
|
-
if (this.loadBalancerIpAddressForWebSocket) {
|
|
251
|
-
|
|
253
|
+
if (!this.wss || (isForceFully && this.isWebScoketConnectedWithoutSetup() === false)) {
|
|
254
|
+
url_1 = _url;
|
|
255
|
+
// if (this.loadBalancerIpAddressForWebSocket) {
|
|
256
|
+
// url = "ws://" + this.loadBalancerIpAddressForWebSocket + ":4003/?connection=";
|
|
257
|
+
// }
|
|
258
|
+
// else
|
|
259
|
+
if (!url_1 && ((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.wssUrl) && this.meetingStartRequest.wssUrl !== null) {
|
|
260
|
+
url_1 = this.meetingStartRequest.wssUrl;
|
|
252
261
|
}
|
|
253
|
-
|
|
254
|
-
|
|
262
|
+
if (!url_1 && this.websocketConnectionUrl) {
|
|
263
|
+
url_1 = this.websocketConnectionUrl;
|
|
255
264
|
}
|
|
256
|
-
if (
|
|
257
|
-
|
|
265
|
+
if (!url_1) {
|
|
266
|
+
return [2 /*return*/];
|
|
267
|
+
}
|
|
268
|
+
if (url_1 !== this.websocketConnectionUrl) {
|
|
269
|
+
if (this.wss) {
|
|
270
|
+
this.wss.close();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (!url_1.includes("connection=")) {
|
|
274
|
+
url_1 = url_1 + "/?connection=";
|
|
275
|
+
}
|
|
276
|
+
debugger;
|
|
277
|
+
if (url_1) {
|
|
278
|
+
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("Connecting to ", url_1);
|
|
258
279
|
this.isWebSocketConnectionInProgress = true;
|
|
259
280
|
if (this.meetingStartRequest && ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.isMobileApp)) {
|
|
260
|
-
this.wss = new WebSocket(
|
|
281
|
+
this.wss = new WebSocket(url_1 + this.connection);
|
|
261
282
|
}
|
|
262
283
|
else {
|
|
263
|
-
this.wss = new WebSocket(
|
|
284
|
+
this.wss = new WebSocket(url_1 + this.connection);
|
|
264
285
|
}
|
|
265
286
|
this.wss.onopen = function (event) {
|
|
266
287
|
// this.checkIfSocketConnected();
|
|
267
288
|
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("connected ----");
|
|
268
289
|
_this.isWebSocketConnectionInProgress = false;
|
|
269
290
|
_this.isSetUpDone = false;
|
|
291
|
+
_this.websocketConnectionUrl = url_1;
|
|
270
292
|
_this.socketCheckTimeout = undefined;
|
|
271
|
-
|
|
293
|
+
if (!isForPreConnect) {
|
|
294
|
+
_this.onSocketConnected();
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
console.log("WebSocket connected in pre connect");
|
|
298
|
+
}
|
|
272
299
|
};
|
|
273
300
|
this.wss.onmessage = function (event) {
|
|
274
301
|
_this.isWebSocketConnectionInProgress = false;
|
|
@@ -289,6 +316,8 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
289
316
|
}
|
|
290
317
|
};
|
|
291
318
|
this.wss.onclose = function (event) {
|
|
319
|
+
debugger;
|
|
320
|
+
_this.isSetUpDone = false;
|
|
292
321
|
_this.isWebSocketConnectionInProgress = false;
|
|
293
322
|
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && ("WebSocket is closed now.");
|
|
294
323
|
// log.warn(event)
|
|
@@ -296,14 +325,23 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
296
325
|
};
|
|
297
326
|
}
|
|
298
327
|
}
|
|
299
|
-
else if (isForceFully === false && this.isWebScoketConnected()) {
|
|
328
|
+
else if (isForceFully === false && !isForPreConnect && this.isWebScoketConnected()) {
|
|
300
329
|
(_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.emitMessageToSource(VaniEvent.OnSocketConnected, {});
|
|
301
330
|
}
|
|
331
|
+
else if (!isForPreConnect && this.isWebScoketConnectedWithoutSetup() && !this.isSetUpDone) {
|
|
332
|
+
this.onSocketConnected();
|
|
333
|
+
}
|
|
302
334
|
return [2 /*return*/];
|
|
303
335
|
});
|
|
304
336
|
});
|
|
305
337
|
};
|
|
306
|
-
WebsocketHandler.prototype.
|
|
338
|
+
WebsocketHandler.prototype.isWebSocketInPreConnect = function () {
|
|
339
|
+
if (this.wss && this.wss.readyState === 1 && !this.isSetUpDone) {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
};
|
|
344
|
+
WebsocketHandler.prototype.isWebScoketConnectedWithoutSetup = function () {
|
|
307
345
|
var _a;
|
|
308
346
|
if (this.wss && this.wss.readyState === 1) {
|
|
309
347
|
return true;
|
|
@@ -311,9 +349,17 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
311
349
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("this.wss.readyState", this.wss, (_a = this.wss) === null || _a === void 0 ? void 0 : _a.readyState);
|
|
312
350
|
return false;
|
|
313
351
|
};
|
|
352
|
+
WebsocketHandler.prototype.isWebScoketConnected = function () {
|
|
353
|
+
var _a;
|
|
354
|
+
if (this.wss && this.wss.readyState === 1 && this.isSetUpDone) {
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("this.wss.readyState", this.wss, (_a = this.wss) === null || _a === void 0 ? void 0 : _a.readyState);
|
|
358
|
+
return false;
|
|
359
|
+
};
|
|
314
360
|
WebsocketHandler.prototype.sendSocketMessage = function (type, data) {
|
|
315
361
|
var _a;
|
|
316
|
-
if (this.
|
|
362
|
+
if (this.isWebScoketConnectedWithoutSetup()) {
|
|
317
363
|
var paylod = { type: type, data: data };
|
|
318
364
|
(_a = this.wss) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(paylod));
|
|
319
365
|
}
|
|
@@ -386,7 +432,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
386
432
|
};
|
|
387
433
|
WebsocketHandler.prototype.socketSubscribeToTopic = function () {
|
|
388
434
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
389
|
-
if (this.
|
|
435
|
+
if (this.isWebScoketConnectedWithoutSetup() === false) {
|
|
390
436
|
return;
|
|
391
437
|
}
|
|
392
438
|
this.communicationHandler.updateSelfParticipantUserId();
|