vani-meeting-client 2.2.3-beta → 2.2.3-beta10
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.js +0 -1
- package/lib/model/Participant.d.ts +3 -1
- package/lib/model/Participant.js +14 -0
- package/lib/model/PeerConnection.d.ts +2 -0
- package/lib/video-call-handler/WebrtcHandler.d.ts +11 -0
- package/lib/video-call-handler/WebrtcHandler.js +84 -13
- package/lib/websocket-handler/WebsocketHandler.d.ts +1 -0
- package/lib/websocket-handler/WebsocketHandler.js +6 -2
- package/package.json +1 -1
package/lib/MeetingHandler.js
CHANGED
|
@@ -483,7 +483,6 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
483
483
|
MeetingHandler.prototype.checkSocket = function () {
|
|
484
484
|
return __awaiter(this, void 0, void 0, function () {
|
|
485
485
|
return __generator(this, function (_a) {
|
|
486
|
-
debugger;
|
|
487
486
|
if (!this.meetingStartRequest) {
|
|
488
487
|
log.error("meetingStartRequestObject not found");
|
|
489
488
|
return [2 /*return*/, false];
|
|
@@ -13,6 +13,8 @@ export declare class Participant {
|
|
|
13
13
|
isAudioEnable: boolean;
|
|
14
14
|
isStartMeetingCalled: boolean;
|
|
15
15
|
isRecordingUser: boolean;
|
|
16
|
-
peerConnections
|
|
16
|
+
private peerConnections;
|
|
17
|
+
getPeerConnections: () => Map<string, PeerConnection>;
|
|
18
|
+
getPeerConnectionsViaUserId: (userId: string) => PeerConnection;
|
|
17
19
|
constructor(_userId: string, _roomId: string, _userData?: any, _isAdmin?: boolean);
|
|
18
20
|
}
|
package/lib/model/Participant.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { PeerConnection } from "./PeerConnection";
|
|
1
2
|
var Participant = /** @class */ (function () {
|
|
2
3
|
function Participant(_userId, _roomId, _userData, _isAdmin) {
|
|
3
4
|
if (_userData === void 0) { _userData = {}; }
|
|
4
5
|
if (_isAdmin === void 0) { _isAdmin = false; }
|
|
6
|
+
var _this = this;
|
|
5
7
|
this.isAdmin = false;
|
|
6
8
|
this.isAudioBlockedByAdmin = false;
|
|
7
9
|
this.isVideoBlockedByAdmin = false;
|
|
@@ -13,6 +15,18 @@ var Participant = /** @class */ (function () {
|
|
|
13
15
|
this.isStartMeetingCalled = false;
|
|
14
16
|
this.isRecordingUser = false;
|
|
15
17
|
this.peerConnections = new Map();
|
|
18
|
+
this.getPeerConnections = function () {
|
|
19
|
+
if (!_this.peerConnections) {
|
|
20
|
+
_this.peerConnections = new Map();
|
|
21
|
+
}
|
|
22
|
+
return _this.peerConnections;
|
|
23
|
+
};
|
|
24
|
+
this.getPeerConnectionsViaUserId = function (userId) {
|
|
25
|
+
if (!_this.getPeerConnections().has(userId)) {
|
|
26
|
+
_this.getPeerConnections().set(userId, new PeerConnection());
|
|
27
|
+
}
|
|
28
|
+
return _this.getPeerConnections().get(userId);
|
|
29
|
+
};
|
|
16
30
|
this.userId = _userId;
|
|
17
31
|
this.roomId = _roomId;
|
|
18
32
|
this.userData = _userData;
|
|
@@ -8,8 +8,19 @@ export declare class WebrtcHandler extends BaseVideoCallHandler {
|
|
|
8
8
|
resumeIncomingTrack(track: Track): void;
|
|
9
9
|
pauseIncomingTrack(track: Track): void;
|
|
10
10
|
onSocketMessage(websocketCallHandler: WebSocketMessageBody): void;
|
|
11
|
+
onNewOffer: (data: {
|
|
12
|
+
sdp: string;
|
|
13
|
+
type: string;
|
|
14
|
+
sender: Participant;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
onNewAnswer: (data: {
|
|
17
|
+
sdp: string;
|
|
18
|
+
type: string;
|
|
19
|
+
sender: Participant;
|
|
20
|
+
}) => Promise<void>;
|
|
11
21
|
onAllParticipants(participants: Participant[]): Promise<void>;
|
|
12
22
|
onUserJoined(participant: Participant): Promise<void>;
|
|
23
|
+
private sendWebrtcMessage;
|
|
13
24
|
init(): Promise<void>;
|
|
14
25
|
onReconnect(): Promise<void>;
|
|
15
26
|
stopTrack(track: Track): void;
|
|
@@ -49,16 +49,65 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
+
import { WebrtcMessageType } from "../websocket-handler/WebsocketHandler";
|
|
52
53
|
import { BaseVideoCallHandler } from "./BaseVideoCallHandler";
|
|
53
54
|
import log from 'loglevel';
|
|
54
55
|
import { LogLevel } from "../model/MeetingStartRequest";
|
|
55
56
|
import { DynamicLibHelper } from "../utility/DynamicLibHelper";
|
|
56
|
-
import { PeerConnection } from "../model/PeerConnection";
|
|
57
57
|
var WebrtcHandler = /** @class */ (function (_super) {
|
|
58
58
|
__extends(WebrtcHandler, _super);
|
|
59
59
|
function WebrtcHandler() {
|
|
60
60
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
61
61
|
_this.dynamicLibHelper = (new DynamicLibHelper());
|
|
62
|
+
_this.onNewOffer = function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
63
|
+
var selfParticpant, participant, peerConnectionObject, peerConnection, answer, messageJson;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
68
|
+
participant = data.sender;
|
|
69
|
+
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
|
|
70
|
+
if (peerConnectionObject) {
|
|
71
|
+
peerConnectionObject.remoteOffer = data.sdp;
|
|
72
|
+
}
|
|
73
|
+
peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
74
|
+
if (!peerConnection) return [3 /*break*/, 2];
|
|
75
|
+
peerConnection.setRemoteDescription(peerConnectionObject.remoteOffer);
|
|
76
|
+
peerConnection.addTransceiver("audio", { direction: "sendrecv" });
|
|
77
|
+
peerConnection.addTransceiver("video", { direction: "sendrecv" });
|
|
78
|
+
return [4 /*yield*/, peerConnection.createAnswer()];
|
|
79
|
+
case 1:
|
|
80
|
+
answer = _a.sent();
|
|
81
|
+
peerConnection.setLocalDescription(answer);
|
|
82
|
+
peerConnectionObject.answer = answer;
|
|
83
|
+
peerConnectionObject.rtcPeerConnection = peerConnection;
|
|
84
|
+
console.log("answer", answer);
|
|
85
|
+
messageJson = { to: participant.userId, type: WebrtcMessageType.SendAnswer, data: answer };
|
|
86
|
+
this.sendWebrtcMessage(messageJson);
|
|
87
|
+
_a.label = 2;
|
|
88
|
+
case 2: return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}); };
|
|
92
|
+
_this.onNewAnswer = function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
93
|
+
var selfParticpant, participant, peerConnectionObject, peerConnection;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
96
|
+
participant = data.sender;
|
|
97
|
+
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
|
|
98
|
+
if (peerConnectionObject) {
|
|
99
|
+
peerConnectionObject.remoteAnswer = data.sdp;
|
|
100
|
+
}
|
|
101
|
+
peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
102
|
+
if (peerConnection) {
|
|
103
|
+
peerConnection.setRemoteDescription(peerConnectionObject.remoteAnswer);
|
|
104
|
+
}
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
}); };
|
|
108
|
+
_this.sendWebrtcMessage = function (data) {
|
|
109
|
+
_this.communicationHandler.sendWebSocketMessage(WebrtcMessageType.WebrtcMessage, data);
|
|
110
|
+
};
|
|
62
111
|
_this.isOfferInitParticipant = function (participant) {
|
|
63
112
|
var selfParticpant = _this.communicationHandler.getSelfParticipant();
|
|
64
113
|
if (participant.userId > selfParticpant.userId) {
|
|
@@ -79,6 +128,27 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
79
128
|
// throw new Error("Method not implemented.");
|
|
80
129
|
};
|
|
81
130
|
WebrtcHandler.prototype.onSocketMessage = function (websocketCallHandler) {
|
|
131
|
+
var _a;
|
|
132
|
+
console.log("websocketCallHandler", websocketCallHandler);
|
|
133
|
+
var data = websocketCallHandler.data;
|
|
134
|
+
if (websocketCallHandler.data.message) {
|
|
135
|
+
data = websocketCallHandler.data.message;
|
|
136
|
+
}
|
|
137
|
+
if (data.sender && data.sender._id) {
|
|
138
|
+
var participant = this.communicationHandler.participantByUserId(data.sender._id);
|
|
139
|
+
if (!participant) {
|
|
140
|
+
data.sender = (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.addParticipantIfNotExist(data.sender, false);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
data.sender = participant;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (websocketCallHandler.type === WebrtcMessageType.SendOffer) {
|
|
147
|
+
this.onNewOffer(data);
|
|
148
|
+
}
|
|
149
|
+
else if (websocketCallHandler.type === WebrtcMessageType.SendAnswer) {
|
|
150
|
+
this.onNewAnswer(data);
|
|
151
|
+
}
|
|
82
152
|
// throw new Error("Method not implemented.");
|
|
83
153
|
};
|
|
84
154
|
WebrtcHandler.prototype.onAllParticipants = function (participants) {
|
|
@@ -94,20 +164,18 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
94
164
|
};
|
|
95
165
|
WebrtcHandler.prototype.onUserJoined = function (participant) {
|
|
96
166
|
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
-
var selfParticpant, isOfferInitParticipant, peerConnectionObject, peerConnection, offer;
|
|
167
|
+
var selfParticpant, isOfferInitParticipant, peerConnectionObject, peerConnection, offer, messageJson;
|
|
98
168
|
return __generator(this, function (_a) {
|
|
99
169
|
switch (_a.label) {
|
|
100
170
|
case 0:
|
|
101
171
|
selfParticpant = this.communicationHandler.getSelfParticipant();
|
|
102
|
-
|
|
172
|
+
console.log(selfParticpant);
|
|
173
|
+
if (!(selfParticpant.userId !== participant.userId && !selfParticpant.getPeerConnections().has(participant.userId))) return [3 /*break*/, 2];
|
|
103
174
|
console.log("onUserJoined ", participant);
|
|
104
175
|
isOfferInitParticipant = this.isOfferInitParticipant(participant);
|
|
105
176
|
if (!!isOfferInitParticipant) return [3 /*break*/, 2];
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
peerConnectionObject = selfParticpant.peerConnections.get(participant.userId);
|
|
110
|
-
peerConnection = this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
177
|
+
peerConnectionObject = selfParticpant.getPeerConnectionsViaUserId(participant.userId);
|
|
178
|
+
peerConnection = peerConnectionObject.rtcPeerConnection ? peerConnectionObject.rtcPeerConnection : this.dynamicLibHelper.getRTCPeerConnection(this.meetingStartRequest);
|
|
111
179
|
if (!peerConnection) return [3 /*break*/, 2];
|
|
112
180
|
peerConnection.addTransceiver("audio", { direction: "sendrecv" });
|
|
113
181
|
peerConnection.addTransceiver("video", { direction: "sendrecv" });
|
|
@@ -116,8 +184,11 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
116
184
|
offer = _a.sent();
|
|
117
185
|
peerConnection.setLocalDescription(offer);
|
|
118
186
|
peerConnectionObject.offer = offer;
|
|
187
|
+
peerConnectionObject.rtcPeerConnection = peerConnection;
|
|
119
188
|
// send offer to peer
|
|
120
189
|
console.log("offer", offer);
|
|
190
|
+
messageJson = { to: participant.userId, type: WebrtcMessageType.SendOffer, data: offer };
|
|
191
|
+
this.sendWebrtcMessage(messageJson);
|
|
121
192
|
_a.label = 2;
|
|
122
193
|
case 2: return [2 /*return*/];
|
|
123
194
|
}
|
|
@@ -136,16 +207,16 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
136
207
|
throw new Error("Method not implemented.");
|
|
137
208
|
};
|
|
138
209
|
WebrtcHandler.prototype.stopTrack = function (track) {
|
|
139
|
-
throw new Error("Method not implemented.");
|
|
210
|
+
// throw new Error("Method not implemented.");
|
|
140
211
|
};
|
|
141
212
|
WebrtcHandler.prototype.pauseTrack = function (track) {
|
|
142
|
-
throw new Error("Method not implemented.");
|
|
213
|
+
// throw new Error("Method not implemented.");
|
|
143
214
|
};
|
|
144
215
|
WebrtcHandler.prototype.resumeTrack = function (track) {
|
|
145
|
-
throw new Error("Method not implemented.");
|
|
216
|
+
// throw new Error("Method not implemented.");
|
|
146
217
|
};
|
|
147
218
|
WebrtcHandler.prototype.sendTrack = function (track) {
|
|
148
|
-
throw new Error("Method not implemented.");
|
|
219
|
+
// throw new Error("Method not implemented.");
|
|
149
220
|
};
|
|
150
221
|
WebrtcHandler.prototype.createDataChannel = function () {
|
|
151
222
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -155,7 +226,7 @@ var WebrtcHandler = /** @class */ (function (_super) {
|
|
|
155
226
|
});
|
|
156
227
|
};
|
|
157
228
|
WebrtcHandler.prototype.sendMessageViaDataChannel = function (messagePayload) {
|
|
158
|
-
throw new Error('Method not implemented.');
|
|
229
|
+
// throw new Error('Method not implemented.');
|
|
159
230
|
};
|
|
160
231
|
return WebrtcHandler;
|
|
161
232
|
}(BaseVideoCallHandler));
|
|
@@ -88,6 +88,7 @@ export var WebSocketBasicEvents;
|
|
|
88
88
|
export var WebrtcMessageType;
|
|
89
89
|
(function (WebrtcMessageType) {
|
|
90
90
|
WebrtcMessageType["SendOffer"] = "SendOffer";
|
|
91
|
+
WebrtcMessageType["WebrtcMessage"] = "WebrtcMessage";
|
|
91
92
|
WebrtcMessageType["SendAnswer"] = "SendAnswer";
|
|
92
93
|
})(WebrtcMessageType || (WebrtcMessageType = {}));
|
|
93
94
|
export var SFUMessageType;
|
|
@@ -278,7 +279,6 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
278
279
|
if (!url_1.includes("connection=")) {
|
|
279
280
|
url_1 = url_1 + "/?connection=";
|
|
280
281
|
}
|
|
281
|
-
debugger;
|
|
282
282
|
if (url_1) {
|
|
283
283
|
this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && log.info("Connecting to ", url_1);
|
|
284
284
|
this.isWebSocketConnectionInProgress = true;
|
|
@@ -322,7 +322,6 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
322
322
|
}
|
|
323
323
|
};
|
|
324
324
|
this.wss.onclose = function (event) {
|
|
325
|
-
debugger;
|
|
326
325
|
_this.isSetUpDone = false;
|
|
327
326
|
_this.isWebSocketConnectionInProgress = false;
|
|
328
327
|
_this.meetingStartRequest && _this.meetingStartRequest.logLevel === LogLevel.Debug && ("WebSocket is closed now.");
|
|
@@ -489,6 +488,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
489
488
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
490
489
|
this.lastPingTimeStamp = new Date().getTime();
|
|
491
490
|
// this.meetingStartRequest && this.meetingStartRequest.logLevel === LogLevel.Debug && console.log("lastPingTimeStamp time ", this.lastPingTimeStamp)
|
|
491
|
+
console.log("message", message);
|
|
492
492
|
var messagejson = JSON.parse(message);
|
|
493
493
|
if (messagejson.type && messagejson.data) {
|
|
494
494
|
var type = messagejson.type;
|
|
@@ -612,9 +612,13 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
612
612
|
}
|
|
613
613
|
};
|
|
614
614
|
WebsocketHandler.prototype.isVideoCallControllerMessageType = function (type) {
|
|
615
|
+
console.log("isVideoCallControllerMessageType", type);
|
|
615
616
|
if (Object.values(SFUMessageType).includes(type)) {
|
|
616
617
|
return true;
|
|
617
618
|
}
|
|
619
|
+
else if (Object.values(WebrtcMessageType).includes(type)) {
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
618
622
|
return false;
|
|
619
623
|
};
|
|
620
624
|
return WebsocketHandler;
|