vani-meeting-client 0.6.1 → 0.6.4
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 +3 -2
- package/lib/model/Event.d.ts +2 -0
- package/lib/model/Event.js +1 -0
- package/lib/websocket-handler/WebsocketHandler.js +23 -14
- package/package.json +1 -1
- package/lib/model/AudioVideoPauseResumeResponse.d.ts +0 -5
- package/lib/model/AudioVideoPauseResumeResponse.js +0 -1
- package/lib/websocket-handler/WebsockerHandler.d.ts +0 -22
- package/lib/websocket-handler/WebsockerHandler.js +0 -272
package/lib/MeetingHandler.js
CHANGED
|
@@ -311,9 +311,10 @@ var MeetingHandler = /** @class */ (function () {
|
|
|
311
311
|
return [];
|
|
312
312
|
};
|
|
313
313
|
MeetingHandler.prototype.isWebScoketConnected = function () {
|
|
314
|
-
var _a;
|
|
314
|
+
var _a, _b;
|
|
315
|
+
console.log("Room Id", (_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.roomId);
|
|
315
316
|
if (this.websocketCallHandler) {
|
|
316
|
-
return (
|
|
317
|
+
return (_b = this.websocketCallHandler) === null || _b === void 0 ? void 0 : _b.isWebScoketConnected();
|
|
317
318
|
}
|
|
318
319
|
return false;
|
|
319
320
|
};
|
package/lib/model/Event.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare enum VaniEvent {
|
|
|
6
6
|
OnSocketError = "onSocketError",
|
|
7
7
|
OnSocketConnected = "onConnected",
|
|
8
8
|
OnSocketReconnectTimeOut = "onReconnectTimeOut",
|
|
9
|
+
OnSocketDisconnected = "onSocketDisconnected",
|
|
9
10
|
OnConnected = "onConnected",
|
|
10
11
|
OnConnectionBack = "connectionBack",
|
|
11
12
|
OnMeetingStartTime = "meetingStartTime",
|
|
@@ -58,6 +59,7 @@ interface VaniConnectionEvents {
|
|
|
58
59
|
[VaniEvent.OnAudioUnblocked]: (participant: Participant) => any;
|
|
59
60
|
[VaniEvent.OnVideoBlocked]: (participant: Participant) => any;
|
|
60
61
|
[VaniEvent.OnAudioBlocked]: (participant: Participant) => any;
|
|
62
|
+
[VaniEvent.OnSocketDisconnected]: () => any;
|
|
61
63
|
}
|
|
62
64
|
export declare interface VaniEventListener {
|
|
63
65
|
on<U extends keyof VaniConnectionEvents>(event: U, listener: VaniConnectionEvents[U]): this;
|
package/lib/model/Event.js
CHANGED
|
@@ -4,6 +4,7 @@ export var VaniEvent;
|
|
|
4
4
|
VaniEvent["OnSocketError"] = "onSocketError";
|
|
5
5
|
VaniEvent["OnSocketConnected"] = "onConnected";
|
|
6
6
|
VaniEvent["OnSocketReconnectTimeOut"] = "onReconnectTimeOut";
|
|
7
|
+
VaniEvent["OnSocketDisconnected"] = "onSocketDisconnected";
|
|
7
8
|
VaniEvent["OnConnected"] = "onConnected";
|
|
8
9
|
VaniEvent["OnConnectionBack"] = "connectionBack";
|
|
9
10
|
VaniEvent["OnMeetingStartTime"] = "meetingStartTime";
|
|
@@ -289,15 +289,19 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
289
289
|
// }
|
|
290
290
|
WebsocketHandler.prototype.onWebSocketClosed = function (event) {
|
|
291
291
|
var _this = this;
|
|
292
|
+
var _a;
|
|
292
293
|
log.info("onWebSocketClosed");
|
|
293
294
|
if (event.wasClean === false) {
|
|
294
295
|
this.socketCheckTimeout = window.setTimeout(function () {
|
|
295
296
|
_this.tryToReconectSocket();
|
|
296
297
|
}, 1000);
|
|
297
298
|
}
|
|
299
|
+
else {
|
|
300
|
+
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(VaniEvent.OnSocketDisconnected, {});
|
|
301
|
+
}
|
|
298
302
|
};
|
|
299
303
|
WebsocketHandler.prototype.tryToReconectSocket = function () {
|
|
300
|
-
var _a;
|
|
304
|
+
var _a, _b;
|
|
301
305
|
log.info("tryToReconectSocket");
|
|
302
306
|
if (this.isWebScoketConnected() === false && this.isEnded === false) {
|
|
303
307
|
this.wss = undefined;
|
|
@@ -307,6 +311,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
307
311
|
else {
|
|
308
312
|
this.socketCheckTimeout = undefined;
|
|
309
313
|
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(VaniEvent.OnSocketReconnectTimeOut, {});
|
|
314
|
+
(_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.emitMessageToSource(VaniEvent.OnSocketDisconnected, {});
|
|
310
315
|
}
|
|
311
316
|
};
|
|
312
317
|
WebsocketHandler.prototype.onSocketConnected = function () {
|
|
@@ -349,7 +354,7 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
349
354
|
}, 200);
|
|
350
355
|
};
|
|
351
356
|
WebsocketHandler.prototype.onMessage = function (message) {
|
|
352
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
357
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
353
358
|
this.lastPingTimeStamp = new Date().getTime();
|
|
354
359
|
var messagejson = JSON.parse(message);
|
|
355
360
|
if (messagejson.type && messagejson.data) {
|
|
@@ -365,25 +370,29 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
365
370
|
else if (type === WebSocketBasicEvents.IsSetupDone) {
|
|
366
371
|
this.onSetupDone(data);
|
|
367
372
|
}
|
|
368
|
-
else if (type === WebSocketBasicEvents.
|
|
369
|
-
console.log(" data.message.participant OnParticipantUpdated", data);
|
|
373
|
+
else if (type === WebSocketBasicEvents.OnNewJoinee) {
|
|
370
374
|
if (data && data.message && data.message.participant) {
|
|
371
375
|
console.log("OnParticipantUpdated from server", data.message.participant);
|
|
372
376
|
(_b = this.communicationHandler) === null || _b === void 0 ? void 0 : _b.addParticipantIfNotExist(data.message.participant, true);
|
|
373
377
|
}
|
|
374
378
|
}
|
|
379
|
+
else if (type === WebSocketBasicEvents.OnParticipantUpdated) {
|
|
380
|
+
if (data) {
|
|
381
|
+
(_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.addParticipantIfNotExist(data, true);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
375
384
|
else if (type === WebSocketBasicEvents.OnUserLeft) {
|
|
376
|
-
(
|
|
385
|
+
(_d = this.communicationHandler) === null || _d === void 0 ? void 0 : _d.onUserLeft(data);
|
|
377
386
|
}
|
|
378
387
|
else if (type === WebSocketBasicEvents.OnServerParticipants) {
|
|
379
|
-
(
|
|
388
|
+
(_e = this.communicationHandler) === null || _e === void 0 ? void 0 : _e.onServerParticipants(data);
|
|
380
389
|
}
|
|
381
390
|
else if (type === WebSocketBasicEvents.OnOldMessages) {
|
|
382
|
-
(
|
|
391
|
+
(_f = this.communicationHandler) === null || _f === void 0 ? void 0 : _f.onOldMessages(data);
|
|
383
392
|
}
|
|
384
393
|
else if (type === WebSocketBasicEvents.OnChat) {
|
|
385
394
|
if (data.message) {
|
|
386
|
-
(
|
|
395
|
+
(_g = this.communicationHandler) === null || _g === void 0 ? void 0 : _g.onMessage(data.message);
|
|
387
396
|
}
|
|
388
397
|
}
|
|
389
398
|
else if (type === WebSocketBasicEvents.OnMeetingStartTime) {
|
|
@@ -392,23 +401,23 @@ var WebsocketHandler = /** @class */ (function (_super) {
|
|
|
392
401
|
if (time > new Date().getTime()) {
|
|
393
402
|
time = new Date().getTime();
|
|
394
403
|
}
|
|
395
|
-
(
|
|
404
|
+
(_h = this.communicationHandler) === null || _h === void 0 ? void 0 : _h.emitMessageToSource(VaniEvent.OnMeetingStartTime, (time + ""));
|
|
396
405
|
}
|
|
397
406
|
}
|
|
398
407
|
else if (type === WebSocketBasicEvents.OnAudioVideoStatusUpdated) {
|
|
399
|
-
(
|
|
408
|
+
(_j = this.communicationHandler) === null || _j === void 0 ? void 0 : _j.onAudioVideoStatusUpdated(data);
|
|
400
409
|
}
|
|
401
410
|
else if (type === WebSocketBasicEvents.OnAudioBlockRequest) {
|
|
402
|
-
(
|
|
411
|
+
(_k = this.communicationHandler) === null || _k === void 0 ? void 0 : _k.onAudioBlocked(data);
|
|
403
412
|
}
|
|
404
413
|
else if (type === WebSocketBasicEvents.OnAudioUnblockRequest) {
|
|
405
|
-
(
|
|
414
|
+
(_l = this.communicationHandler) === null || _l === void 0 ? void 0 : _l.onAudioUnblocked(data);
|
|
406
415
|
}
|
|
407
416
|
else if (type === WebSocketBasicEvents.OnVideoBlockRequest) {
|
|
408
|
-
(
|
|
417
|
+
(_m = this.communicationHandler) === null || _m === void 0 ? void 0 : _m.onVideoBlocked(data);
|
|
409
418
|
}
|
|
410
419
|
else if (type === WebSocketBasicEvents.OnVideoUnblockRequest) {
|
|
411
|
-
(
|
|
420
|
+
(_o = this.communicationHandler) === null || _o === void 0 ? void 0 : _o.onVideoUnblocked(data);
|
|
412
421
|
}
|
|
413
422
|
}
|
|
414
423
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { WebSocketEvents } from '..';
|
|
2
|
-
import { Base } from '../base/Base';
|
|
3
|
-
export declare class WebsockerHandler extends Base {
|
|
4
|
-
private loadBalancerIpAddressForWebSocket?;
|
|
5
|
-
private isEnded;
|
|
6
|
-
private isWebSocketConnectionInProgress;
|
|
7
|
-
private wss?;
|
|
8
|
-
private connection;
|
|
9
|
-
private isSetUpDone;
|
|
10
|
-
private socketCheckTimeout?;
|
|
11
|
-
private setUpTry;
|
|
12
|
-
cleanup(): void;
|
|
13
|
-
startSocketConnection(): Promise<void>;
|
|
14
|
-
private connect;
|
|
15
|
-
isWebScoketConnected(): boolean;
|
|
16
|
-
sendSocketMessage(type: WebSocketEvents, data: any): void;
|
|
17
|
-
private tryToReconectSocket;
|
|
18
|
-
private onSocketConnected;
|
|
19
|
-
private socketSubscribeToTopic;
|
|
20
|
-
private askIfSetupDone;
|
|
21
|
-
private onMessage;
|
|
22
|
-
}
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.WebsockerHandler = void 0;
|
|
55
|
-
var axios_1 = require("axios");
|
|
56
|
-
var __1 = require("..");
|
|
57
|
-
var Base_1 = require("../base/Base");
|
|
58
|
-
var log = require("loglevel");
|
|
59
|
-
var ConnectionType;
|
|
60
|
-
(function (ConnectionType) {
|
|
61
|
-
ConnectionType["new"] = "new";
|
|
62
|
-
ConnectionType["reconnect"] = "reconnect";
|
|
63
|
-
})(ConnectionType || (ConnectionType = {}));
|
|
64
|
-
var WebsockerHandler = /** @class */ (function (_super) {
|
|
65
|
-
__extends(WebsockerHandler, _super);
|
|
66
|
-
function WebsockerHandler() {
|
|
67
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
68
|
-
_this.isEnded = false;
|
|
69
|
-
_this.isWebSocketConnectionInProgress = false;
|
|
70
|
-
_this.connection = ConnectionType.new;
|
|
71
|
-
_this.isSetUpDone = false;
|
|
72
|
-
_this.setUpTry = 0;
|
|
73
|
-
return _this;
|
|
74
|
-
}
|
|
75
|
-
WebsockerHandler.prototype.cleanup = function () {
|
|
76
|
-
this.loadBalancerIpAddressForWebSocket = undefined;
|
|
77
|
-
this.isEnded = true;
|
|
78
|
-
if (this.wss) {
|
|
79
|
-
this.wss.close();
|
|
80
|
-
this.wss = undefined;
|
|
81
|
-
}
|
|
82
|
-
if (this.socketCheckTimeout) {
|
|
83
|
-
clearTimeout(this.socketCheckTimeout);
|
|
84
|
-
this.socketCheckTimeout = undefined;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
WebsockerHandler.prototype.startSocketConnection = function () {
|
|
88
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
-
var request, urlToGetIpAddress, config;
|
|
90
|
-
var _this = this;
|
|
91
|
-
return __generator(this, function (_a) {
|
|
92
|
-
if (!this.meetingStartRequest) {
|
|
93
|
-
log.warn("meetingStartRequest not found on startSocketConnection");
|
|
94
|
-
return [2 /*return*/];
|
|
95
|
-
}
|
|
96
|
-
if (this.meetingStartRequest.dynamicWebSocketFetchBaseUrl) {
|
|
97
|
-
if (this.meetingStartRequest.dynamicWebSocketFetchBaseUrl.endsWith("/") === false) {
|
|
98
|
-
this.meetingStartRequest.dynamicWebSocketFetchBaseUrl = this.meetingStartRequest.dynamicWebSocketFetchBaseUrl + "/";
|
|
99
|
-
}
|
|
100
|
-
request = { meeting_id: this.meetingStartRequest.roomId, estimated_users: this.meetingStartRequest.numberOfUsers };
|
|
101
|
-
urlToGetIpAddress = this.meetingStartRequest.dynamicWebSocketFetchBaseUrl + "api/getIpAddressForMeeting";
|
|
102
|
-
log.info(JSON.stringify(request));
|
|
103
|
-
config = {
|
|
104
|
-
headers: {
|
|
105
|
-
'Content-Type': 'application/json'
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
axios_1.default
|
|
109
|
-
.post(urlToGetIpAddress, request, config)
|
|
110
|
-
.then(function (response) {
|
|
111
|
-
log.info("response ", response.data);
|
|
112
|
-
if (response && response.data && response.data.status === true && response.data.ipAddress && response.data.ipAddress !== null) {
|
|
113
|
-
_this.loadBalancerIpAddressForWebSocket = response.data.ipAddress;
|
|
114
|
-
}
|
|
115
|
-
_this.connect(false);
|
|
116
|
-
})
|
|
117
|
-
.catch(function (error) {
|
|
118
|
-
_this.connect(false);
|
|
119
|
-
log.warn(error);
|
|
120
|
-
_this.connect(false);
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
this.connect(false);
|
|
125
|
-
}
|
|
126
|
-
return [2 /*return*/];
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
WebsockerHandler.prototype.connect = function (isForceFully) {
|
|
131
|
-
var _a, _b, _c;
|
|
132
|
-
if (isForceFully === void 0) { isForceFully = false; }
|
|
133
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
-
var url;
|
|
135
|
-
var _this = this;
|
|
136
|
-
return __generator(this, function (_d) {
|
|
137
|
-
if (this.isEnded === true || this.isWebSocketConnectionInProgress) {
|
|
138
|
-
return [2 /*return*/];
|
|
139
|
-
}
|
|
140
|
-
if (!this.wss || (isForceFully && this.isWebScoketConnected() === false)) {
|
|
141
|
-
url = void 0;
|
|
142
|
-
if (this.loadBalancerIpAddressForWebSocket) {
|
|
143
|
-
url = "ws://" + this.loadBalancerIpAddressForWebSocket + ":4003/?connection=";
|
|
144
|
-
}
|
|
145
|
-
else if (((_a = this.meetingStartRequest) === null || _a === void 0 ? void 0 : _a.wssUrl) && this.meetingStartRequest.wssUrl !== null) {
|
|
146
|
-
url = this.meetingStartRequest.wssUrl;
|
|
147
|
-
}
|
|
148
|
-
if (url) {
|
|
149
|
-
log.info("Connecting to ", url);
|
|
150
|
-
this.isWebSocketConnectionInProgress = true;
|
|
151
|
-
if ((_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.isMobileApp) {
|
|
152
|
-
this.wss = new WebSocket(url + this.connection);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
this.wss = new WebSocket(url + this.connection);
|
|
156
|
-
}
|
|
157
|
-
this.wss.addEventListener('open', function (event) {
|
|
158
|
-
log.info("connected ----");
|
|
159
|
-
_this.isWebSocketConnectionInProgress = false;
|
|
160
|
-
_this.isSetUpDone = false;
|
|
161
|
-
_this.socketCheckTimeout = undefined;
|
|
162
|
-
_this.onSocketConnected();
|
|
163
|
-
});
|
|
164
|
-
this.wss.onmessage = function (event) {
|
|
165
|
-
_this.isWebSocketConnectionInProgress = false;
|
|
166
|
-
_this.onMessage(event.data);
|
|
167
|
-
};
|
|
168
|
-
this.wss.onerror = function (event) {
|
|
169
|
-
var _a;
|
|
170
|
-
_this.isWebSocketConnectionInProgress = false;
|
|
171
|
-
(_a = _this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(__1.Event.OnSocketError, event);
|
|
172
|
-
if (_this.wss) {
|
|
173
|
-
_this.wss.close();
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
this.wss.onclose = function (event) {
|
|
177
|
-
_this.isWebSocketConnectionInProgress = false;
|
|
178
|
-
log.info("WebSocket is closed now.");
|
|
179
|
-
log.warn(event);
|
|
180
|
-
if (event.wasClean === false) {
|
|
181
|
-
_this.socketCheckTimeout = setTimeout(_this.tryToReconectSocket, 1000);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
else if (isForceFully === false && this.isWebScoketConnected()) {
|
|
187
|
-
(_c = this.communicationHandler) === null || _c === void 0 ? void 0 : _c.emitMessageToSource(__1.Event.OnSocketConnected, {});
|
|
188
|
-
}
|
|
189
|
-
return [2 /*return*/];
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
WebsockerHandler.prototype.isWebScoketConnected = function () {
|
|
194
|
-
if (this.wss && this.wss.readyState === 1) {
|
|
195
|
-
return true;
|
|
196
|
-
}
|
|
197
|
-
return false;
|
|
198
|
-
};
|
|
199
|
-
WebsockerHandler.prototype.sendSocketMessage = function (type, data) {
|
|
200
|
-
var _a;
|
|
201
|
-
if (this.isWebScoketConnected()) {
|
|
202
|
-
var paylod = { type: type, data: data };
|
|
203
|
-
(_a = this.wss) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify(paylod));
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
WebsockerHandler.prototype.tryToReconectSocket = function () {
|
|
207
|
-
var _a;
|
|
208
|
-
if (this.isWebScoketConnected() === false && this.isEnded === false) {
|
|
209
|
-
this.wss = undefined;
|
|
210
|
-
this.connection = ConnectionType.reconnect;
|
|
211
|
-
this.connect(true);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
this.socketCheckTimeout = undefined;
|
|
215
|
-
(_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.emitMessageToSource(__1.Event.OnSocketReconnectTimeOut, {});
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
WebsockerHandler.prototype.onSocketConnected = function () {
|
|
219
|
-
this.socketSubscribeToTopic();
|
|
220
|
-
};
|
|
221
|
-
WebsockerHandler.prototype.socketSubscribeToTopic = function () {
|
|
222
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
223
|
-
if (this.isWebScoketConnected() === false) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
var config = {
|
|
227
|
-
participant: (_a = this.communicationHandler) === null || _a === void 0 ? void 0 : _a.getSelfParticipant(), apiData: (_b = this.meetingStartRequest) === null || _b === void 0 ? void 0 : _b.apiData,
|
|
228
|
-
appId: (_c = this.meetingStartRequest) === null || _c === void 0 ? void 0 : _c.appId, sfuRequired: (((_d = this.meetingStartRequest) === null || _d === void 0 ? void 0 : _d.meetingType) === __1.MeetingType.SFU), numberOfUsers: (_e = this.meetingStartRequest) === null || _e === void 0 ? void 0 : _e.numberOfUsers, meetId: (_f = this.meetingStartRequest) === null || _f === void 0 ? void 0 : _f.roomId
|
|
229
|
-
};
|
|
230
|
-
this.sendSocketMessage(__1.WebSocketEvents.Config, config);
|
|
231
|
-
var hostNotificationRoom = { roomId: (_g = this.meetingStartRequest) === null || _g === void 0 ? void 0 : _g.userId, id: (_h = this.meetingStartRequest) === null || _h === void 0 ? void 0 : _h.userId };
|
|
232
|
-
this.sendSocketMessage(__1.WebSocketEvents.JoinRoom, hostNotificationRoom);
|
|
233
|
-
var roomForAllClient = { roomId: (_j = this.meetingStartRequest) === null || _j === void 0 ? void 0 : _j.roomId, id: (_k = this.meetingStartRequest) === null || _k === void 0 ? void 0 : _k.userId };
|
|
234
|
-
this.sendSocketMessage(__1.WebSocketEvents.JoinRoom, roomForAllClient);
|
|
235
|
-
this.setUpTry = 0;
|
|
236
|
-
this.askIfSetupDone();
|
|
237
|
-
};
|
|
238
|
-
WebsockerHandler.prototype.askIfSetupDone = function () {
|
|
239
|
-
var _this = this;
|
|
240
|
-
if (this.isSetUpDone || this.setUpTry > 10) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
if (!this.meetingStartRequest) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
var checkIfSetupDone = { to: this.meetingStartRequest.userId };
|
|
247
|
-
this.sendSocketMessage(__1.WebSocketEvents.IsSetupDone, checkIfSetupDone);
|
|
248
|
-
log.info("Vani setupDone asked");
|
|
249
|
-
setTimeout(function () {
|
|
250
|
-
if (_this.isSetUpDone || _this.setUpTry > 10) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
_this.askIfSetupDone();
|
|
254
|
-
_this.setUpTry = _this.setUpTry + 1;
|
|
255
|
-
}, 200);
|
|
256
|
-
};
|
|
257
|
-
WebsockerHandler.prototype.onMessage = function (message) {
|
|
258
|
-
var messagejson = JSON.parse(message);
|
|
259
|
-
if (messagejson.type && messagejson.data) {
|
|
260
|
-
var type = messagejson.type;
|
|
261
|
-
var data = messagejson.data;
|
|
262
|
-
// if (type === WebSocketEvents.IsSetupDone) {
|
|
263
|
-
// }
|
|
264
|
-
// else
|
|
265
|
-
if (type === __1.WebSocketEvents.Ping) {
|
|
266
|
-
this.sendSocketMessage(__1.WebSocketEvents.Pong, data);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
return WebsockerHandler;
|
|
271
|
-
}(Base_1.Base));
|
|
272
|
-
exports.WebsockerHandler = WebsockerHandler;
|