@signalwire/js 1.3.0-dev.1 → 1.4.0
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/README.md +4 -2
- package/dist/esm/common/src/BaseSession.d.ts +8 -13
- package/dist/esm/common/src/BaseSession.js +33 -46
- package/dist/esm/common/src/BrowserSession.d.ts +20 -57
- package/dist/esm/common/src/BrowserSession.js +91 -359
- package/dist/esm/common/src/messages/Verto.d.ts +1 -10
- package/dist/esm/common/src/messages/Verto.js +1 -16
- package/dist/esm/common/src/messages/verto/Login.d.ts +1 -13
- package/dist/esm/common/src/messages/verto/Login.js +2 -5
- package/dist/esm/common/src/services/BroadcastHandler.js +3 -2
- package/dist/esm/common/src/services/Connection.d.ts +2 -2
- package/dist/esm/common/src/services/Handler.d.ts +8 -9
- package/dist/esm/common/src/services/Handler.js +38 -41
- package/dist/esm/common/src/util/constants/index.d.ts +0 -1
- package/dist/esm/common/src/util/constants/index.js +0 -1
- package/dist/esm/common/src/util/helpers.d.ts +10 -3
- package/dist/esm/common/src/util/helpers.js +11 -6
- package/dist/esm/common/src/util/interfaces.d.ts +56 -21
- package/dist/esm/common/src/util/interfaces.js +1 -0
- package/dist/esm/common/src/util/logger.js +1 -4
- package/dist/esm/common/src/util/webrtc/index.d.ts +2 -7
- package/dist/esm/common/src/util/webrtc/index.js +2 -63
- package/dist/esm/common/src/webrtc/BaseCall.d.ts +79 -0
- package/dist/esm/common/src/webrtc/BaseCall.js +711 -0
- package/dist/esm/common/src/webrtc/Call.d.ts +5 -5
- package/dist/esm/common/src/webrtc/Call.js +15 -34
- package/dist/esm/common/src/webrtc/CantinaAuth.d.ts +14 -9
- package/dist/esm/common/src/webrtc/CantinaAuth.js +18 -24
- package/dist/esm/common/src/webrtc/LayoutHandler.d.ts +3 -0
- package/dist/esm/common/src/webrtc/LayoutHandler.js +36 -0
- package/dist/esm/common/src/webrtc/Peer.d.ts +23 -0
- package/dist/esm/common/src/webrtc/Peer.js +169 -0
- package/dist/esm/common/src/webrtc/VertoHandler.d.ts +11 -2
- package/dist/esm/common/src/webrtc/VertoHandler.js +187 -147
- package/dist/esm/common/src/webrtc/constants.d.ts +12 -27
- package/dist/esm/common/src/webrtc/constants.js +11 -33
- package/dist/esm/common/src/webrtc/helpers.d.ts +25 -19
- package/dist/esm/common/src/webrtc/helpers.js +190 -162
- package/dist/esm/common/src/webrtc/interfaces.d.ts +52 -209
- package/dist/esm/common/src/webrtc/interfaces.js +1 -0
- package/dist/esm/js/index.d.ts +1 -3
- package/dist/esm/js/index.js +2 -2
- package/dist/esm/js/src/SignalWire.d.ts +2 -0
- package/dist/esm/js/src/SignalWire.js +13 -0
- package/dist/esm/js/src/Verto.d.ts +2 -8
- package/dist/esm/js/src/Verto.js +14 -50
- package/dist/index.min.js +2 -6
- package/dist/index.min.js.LICENSE.txt +5 -0
- package/package.json +24 -19
- package/dist/esm/common/src/webrtc/ChatChannelHandler.d.ts +0 -5
- package/dist/esm/common/src/webrtc/ChatChannelHandler.js +0 -22
- package/dist/esm/common/src/webrtc/Conference.d.ts +0 -15
- package/dist/esm/common/src/webrtc/Conference.js +0 -68
- package/dist/esm/common/src/webrtc/ConferenceListChannelHandler.d.ts +0 -5
- package/dist/esm/common/src/webrtc/ConferenceListChannelHandler.js +0 -77
- package/dist/esm/common/src/webrtc/InfoChannelHandler.d.ts +0 -7
- package/dist/esm/common/src/webrtc/InfoChannelHandler.js +0 -85
- package/dist/esm/common/src/webrtc/LaChannelHandler.d.ts +0 -5
- package/dist/esm/common/src/webrtc/LaChannelHandler.js +0 -58
- package/dist/esm/common/src/webrtc/ModChannelHandler.d.ts +0 -71
- package/dist/esm/common/src/webrtc/ModChannelHandler.js +0 -267
- package/dist/esm/common/src/webrtc/RTCPeer.d.ts +0 -51
- package/dist/esm/common/src/webrtc/RTCPeer.js +0 -556
- package/dist/esm/common/src/webrtc/WebRTCCall.d.ts +0 -182
- package/dist/esm/common/src/webrtc/WebRTCCall.js +0 -784
- package/dist/esm/common/src/webrtc/deviceHelpers.d.ts +0 -18
- package/dist/esm/common/src/webrtc/deviceHelpers.js +0 -113
- package/dist/esm/common/src/webrtc/sdpHelpers.d.ts +0 -3
- package/dist/esm/common/src/webrtc/sdpHelpers.js +0 -56
|
@@ -18,175 +18,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
18
18
|
}
|
|
19
19
|
return t;
|
|
20
20
|
};
|
|
21
|
+
import logger from './util/logger';
|
|
21
22
|
import BaseSession from './BaseSession';
|
|
22
|
-
import {
|
|
23
|
+
import { registerOnce, trigger } from './services/Handler';
|
|
23
24
|
import { SwEvent, SESSION_ID } from './util/constants';
|
|
24
|
-
import { State, DeviceType
|
|
25
|
-
import { removeUnsupportedConstraints,
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
28
|
-
import { Execute } from './messages/Blade';
|
|
29
|
-
import { Unsubscribe, Subscribe, Broadcast, JSApi } from './messages/Verto';
|
|
25
|
+
import { State, DeviceType } from './webrtc/constants';
|
|
26
|
+
import { getDevices, scanResolutions, removeUnsupportedConstraints, checkDeviceIdConstraints, destructSubscribeResponse, getUserMedia, assureDeviceId } from './webrtc/helpers';
|
|
27
|
+
import { findElementByType } from './util/helpers';
|
|
28
|
+
import { Unsubscribe, Subscribe, Broadcast } from './messages/Verto';
|
|
30
29
|
import { localStorage } from './util/storage/';
|
|
31
30
|
import { stopStream } from './util/webrtc';
|
|
32
|
-
import laChannelHandler from './webrtc/LaChannelHandler';
|
|
33
|
-
import modChannelHandler from './webrtc/ModChannelHandler';
|
|
34
|
-
import infoChannelHandler from './webrtc/InfoChannelHandler';
|
|
35
|
-
import ConferenceListChannelHandler, { publicConferenceListMethods } from './webrtc/ConferenceListChannelHandler';
|
|
36
|
-
import Conference from './webrtc/Conference';
|
|
37
31
|
export default class BrowserSession extends BaseSession {
|
|
38
32
|
constructor() {
|
|
39
33
|
super(...arguments);
|
|
40
34
|
this.calls = {};
|
|
41
|
-
this.conferences = {};
|
|
42
|
-
this.channelToCallIds = new Map();
|
|
43
35
|
this.autoRecoverCalls = true;
|
|
44
|
-
this.incognito = false;
|
|
45
36
|
this._iceServers = [];
|
|
46
37
|
this._localElement = null;
|
|
47
38
|
this._remoteElement = null;
|
|
48
39
|
this._jwtAuth = true;
|
|
40
|
+
this._devices = {};
|
|
49
41
|
this._audioConstraints = true;
|
|
50
42
|
this._videoConstraints = false;
|
|
51
43
|
this._speaker = null;
|
|
52
|
-
this._purgeTimeout = null;
|
|
53
|
-
this._experimental = false;
|
|
54
|
-
this.watchVertoConferences = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
this.conferences = {};
|
|
56
|
-
const currentConfList = yield this.vertoConferenceList(params);
|
|
57
|
-
currentConfList.forEach(row => {
|
|
58
|
-
this.conferences[row.uuid] = new Conference(this, row);
|
|
59
|
-
});
|
|
60
|
-
const infoChannel = 'conference-info';
|
|
61
|
-
const laChannel = 'conference-liveArray';
|
|
62
|
-
const modChannel = 'conference-mod';
|
|
63
|
-
const channels = [infoChannel, laChannel, modChannel];
|
|
64
|
-
this._detachChannels(channels);
|
|
65
|
-
const result = yield this.vertoSubscribe({
|
|
66
|
-
nodeId: this.nodeid,
|
|
67
|
-
channels,
|
|
68
|
-
});
|
|
69
|
-
const { subscribed = [], alreadySubscribed = [] } = destructSubscribeResponse(result);
|
|
70
|
-
const all = subscribed.concat(alreadySubscribed);
|
|
71
|
-
if (all.includes(laChannel)) {
|
|
72
|
-
this._addSubscription(this.relayProtocol, laChannelHandler.bind(this, this), laChannel);
|
|
73
|
-
}
|
|
74
|
-
if (all.includes(infoChannel)) {
|
|
75
|
-
this.off('signalwire.notification', this._watchRoomsNotificationHandler);
|
|
76
|
-
this.on('signalwire.notification', this._watchRoomsNotificationHandler);
|
|
77
|
-
this._addSubscription(this.relayProtocol, infoChannelHandler.bind(this, this), infoChannel);
|
|
78
|
-
}
|
|
79
|
-
if (all.includes(modChannel)) {
|
|
80
|
-
this._addSubscription(this.relayProtocol, modChannelHandler.bind(this, this), modChannel);
|
|
81
|
-
}
|
|
82
|
-
return currentConfList;
|
|
83
|
-
});
|
|
84
|
-
this._watchRoomsNotificationHandler = (event) => {
|
|
85
|
-
if (event.type !== 'conferenceUpdate') {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
switch (event.action) {
|
|
89
|
-
case 'clear':
|
|
90
|
-
Object.keys(this.conferences).forEach(uuid => {
|
|
91
|
-
if (this.conferences[uuid].confName === event.confName) {
|
|
92
|
-
delete this.conferences[uuid];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
break;
|
|
96
|
-
case 'conferenceInfo':
|
|
97
|
-
const conferenceState = event.conferenceState;
|
|
98
|
-
const { uuid, running } = conferenceState;
|
|
99
|
-
if (running) {
|
|
100
|
-
const params = destructConferenceState(conferenceState);
|
|
101
|
-
this.conferences[uuid] = new Conference(this, params);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
delete this.conferences[uuid];
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
this.unwatchVertoConferences = () => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
this.conferences = {};
|
|
111
|
-
const infoChannel = 'conference-info';
|
|
112
|
-
const laChannel = 'conference-liveArray';
|
|
113
|
-
const modChannel = 'conference-mod';
|
|
114
|
-
const channels = [infoChannel, laChannel, modChannel];
|
|
115
|
-
this._detachChannels(channels);
|
|
116
|
-
yield this.vertoUnsubscribe({
|
|
117
|
-
nodeId: this.nodeid,
|
|
118
|
-
channels,
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
this._detachChannels = (channels) => {
|
|
122
|
-
channels.forEach(channel => {
|
|
123
|
-
deRegister(this.relayProtocol, null, channel);
|
|
124
|
-
this._removeSubscription(this.relayProtocol, channel);
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
this.watchVertoConferenceList = () => __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
this.conferences = {};
|
|
129
|
-
const listChannel = 'conference-list';
|
|
130
|
-
const channels = [listChannel];
|
|
131
|
-
this._detachChannels(channels);
|
|
132
|
-
const result = yield this.vertoSubscribe({
|
|
133
|
-
nodeId: this.nodeid,
|
|
134
|
-
channels,
|
|
135
|
-
});
|
|
136
|
-
const { subscribed = [], alreadySubscribed = [] } = destructSubscribeResponse(result);
|
|
137
|
-
const all = subscribed.concat(alreadySubscribed);
|
|
138
|
-
if (all.includes(listChannel)) {
|
|
139
|
-
this._addSubscription(this.relayProtocol, ConferenceListChannelHandler.bind(this, this), listChannel);
|
|
140
|
-
const listObject = {
|
|
141
|
-
session: this,
|
|
142
|
-
nodeId: this.nodeid,
|
|
143
|
-
channel: listChannel,
|
|
144
|
-
};
|
|
145
|
-
Object.keys(publicConferenceListMethods).forEach(method => {
|
|
146
|
-
Object.defineProperty(this, method, {
|
|
147
|
-
configurable: true,
|
|
148
|
-
writable: true,
|
|
149
|
-
value: publicConferenceListMethods[method].bind(listObject)
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
this.conferenceListBootstrap();
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
this.unwatchVertoConferenceList = () => __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
const listChannel = 'conference-list';
|
|
157
|
-
const channels = [listChannel];
|
|
158
|
-
this._detachChannels(channels);
|
|
159
|
-
yield this.vertoUnsubscribe({
|
|
160
|
-
nodeId: this.nodeid,
|
|
161
|
-
channels,
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
get callIds() {
|
|
166
|
-
return Object.keys(this.calls);
|
|
167
|
-
}
|
|
168
|
-
addChannelCallIdEntry(channel, callId) {
|
|
169
|
-
const current = this.channelToCallIds.get(channel) || [];
|
|
170
|
-
const filtered = current.filter(id => id !== callId);
|
|
171
|
-
filtered.push(callId);
|
|
172
|
-
this.channelToCallIds.set(channel, filtered);
|
|
173
|
-
}
|
|
174
|
-
removeChannelCallIdEntry(channel, callId) {
|
|
175
|
-
const current = this.channelToCallIds.get(channel) || [];
|
|
176
|
-
const filtered = current.filter(id => id !== callId);
|
|
177
|
-
this.channelToCallIds.set(channel, filtered);
|
|
178
44
|
}
|
|
179
45
|
get reconnectDelay() {
|
|
180
46
|
return 1000;
|
|
181
47
|
}
|
|
48
|
+
_handleBladeConnectResponse(response) {
|
|
49
|
+
const { ice_servers = [] } = response;
|
|
50
|
+
this.iceServers = ice_servers;
|
|
51
|
+
}
|
|
182
52
|
connect() {
|
|
183
53
|
const _super = Object.create(null, {
|
|
184
54
|
connect: { get: () => super.connect }
|
|
185
55
|
});
|
|
186
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
|
|
188
|
-
this.sessionid = yield localStorage.getItem(SESSION_ID);
|
|
189
|
-
}
|
|
57
|
+
this.sessionid = yield localStorage.getItem(SESSION_ID);
|
|
190
58
|
_super.connect.call(this);
|
|
191
59
|
});
|
|
192
60
|
}
|
|
@@ -202,19 +70,17 @@ export default class BrowserSession extends BaseSession {
|
|
|
202
70
|
}
|
|
203
71
|
});
|
|
204
72
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
this.calls = {};
|
|
73
|
+
logout() {
|
|
74
|
+
this.disconnect();
|
|
208
75
|
}
|
|
209
76
|
disconnect() {
|
|
210
77
|
const _super = Object.create(null, {
|
|
211
78
|
disconnect: { get: () => super.disconnect }
|
|
212
79
|
});
|
|
213
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return _super.disconnect.call(this);
|
|
81
|
+
Object.keys(this.calls).forEach(k => this.calls[k].setState(State.Purge));
|
|
82
|
+
this.calls = {};
|
|
83
|
+
yield _super.disconnect.call(this);
|
|
218
84
|
});
|
|
219
85
|
}
|
|
220
86
|
speedTest(bytes) {
|
|
@@ -268,17 +134,52 @@ export default class BrowserSession extends BaseSession {
|
|
|
268
134
|
validateDeviceId(id, label, kind) {
|
|
269
135
|
return assureDeviceId(id, label, kind);
|
|
270
136
|
}
|
|
271
|
-
|
|
272
|
-
return
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
137
|
+
refreshDevices() {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
logger.warn('This method has been deprecated. Use getDevices() instead.');
|
|
140
|
+
const cache = {};
|
|
141
|
+
['videoinput', 'audioinput', 'audiooutput'].map((kind) => {
|
|
142
|
+
cache[kind] = {};
|
|
143
|
+
Object.defineProperty(cache[kind], 'toArray', {
|
|
144
|
+
value: function () {
|
|
145
|
+
return Object.keys(this).map(k => this[k]);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
const devices = yield this.getDevices();
|
|
150
|
+
devices.forEach((t) => {
|
|
151
|
+
if (cache.hasOwnProperty(t.kind)) {
|
|
152
|
+
cache[t.kind][t.deviceId] = t;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
this._devices = cache;
|
|
156
|
+
return this.devices;
|
|
157
|
+
});
|
|
276
158
|
}
|
|
277
|
-
|
|
278
|
-
return
|
|
159
|
+
get devices() {
|
|
160
|
+
return this._devices || {};
|
|
279
161
|
}
|
|
280
162
|
getDeviceResolutions(deviceId) {
|
|
281
|
-
return
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
try {
|
|
165
|
+
return yield scanResolutions(deviceId);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
get videoDevices() {
|
|
173
|
+
logger.warn('This property has been deprecated. Use getVideoDevices() instead.');
|
|
174
|
+
return this._devices.videoinput || {};
|
|
175
|
+
}
|
|
176
|
+
get audioInDevices() {
|
|
177
|
+
logger.warn('This property has been deprecated. Use getAudioInDevices() instead.');
|
|
178
|
+
return this._devices.audioinput || {};
|
|
179
|
+
}
|
|
180
|
+
get audioOutDevices() {
|
|
181
|
+
logger.warn('This property has been deprecated. Use getAudioOutDevices() instead.');
|
|
182
|
+
return this._devices.audiooutput || {};
|
|
282
183
|
}
|
|
283
184
|
get mediaConstraints() {
|
|
284
185
|
return { audio: this._audioConstraints, video: this._videoConstraints };
|
|
@@ -294,8 +195,6 @@ export default class BrowserSession extends BaseSession {
|
|
|
294
195
|
});
|
|
295
196
|
}
|
|
296
197
|
disableMicrophone() {
|
|
297
|
-
this.micId = null;
|
|
298
|
-
this.micLabel = null;
|
|
299
198
|
this._audioConstraints = false;
|
|
300
199
|
}
|
|
301
200
|
enableMicrophone() {
|
|
@@ -312,8 +211,6 @@ export default class BrowserSession extends BaseSession {
|
|
|
312
211
|
});
|
|
313
212
|
}
|
|
314
213
|
disableWebcam() {
|
|
315
|
-
this.camId = null;
|
|
316
|
-
this.camLabel = null;
|
|
317
214
|
this._videoConstraints = false;
|
|
318
215
|
}
|
|
319
216
|
enableWebcam() {
|
|
@@ -337,226 +234,61 @@ export default class BrowserSession extends BaseSession {
|
|
|
337
234
|
return this._speaker;
|
|
338
235
|
}
|
|
339
236
|
set localElement(tag) {
|
|
340
|
-
this._localElement = tag;
|
|
237
|
+
this._localElement = findElementByType(tag);
|
|
341
238
|
}
|
|
342
239
|
get localElement() {
|
|
343
240
|
return this._localElement;
|
|
344
241
|
}
|
|
345
242
|
set remoteElement(tag) {
|
|
346
|
-
this._remoteElement = tag;
|
|
243
|
+
this._remoteElement = findElementByType(tag);
|
|
347
244
|
}
|
|
348
245
|
get remoteElement() {
|
|
349
246
|
return this._remoteElement;
|
|
350
247
|
}
|
|
351
|
-
vertoBroadcast({ nodeId, channel, data }) {
|
|
352
|
-
|
|
248
|
+
vertoBroadcast({ nodeId, channel: eventChannel = '', data }) {
|
|
249
|
+
if (!eventChannel) {
|
|
250
|
+
throw new Error('Invalid channel for broadcast: ' + eventChannel);
|
|
251
|
+
}
|
|
252
|
+
const msg = new Broadcast({ sessid: this.sessionid, eventChannel, data });
|
|
353
253
|
if (nodeId) {
|
|
354
254
|
msg.targetNodeId = nodeId;
|
|
355
255
|
}
|
|
356
|
-
|
|
256
|
+
this.execute(msg).catch(error => error);
|
|
357
257
|
}
|
|
358
|
-
vertoSubscribe({ nodeId, channels
|
|
258
|
+
vertoSubscribe({ nodeId, channels: eventChannel = [], handler }) {
|
|
359
259
|
return __awaiter(this, void 0, void 0, function* () {
|
|
360
|
-
|
|
361
|
-
if (
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
try {
|
|
365
|
-
const response = yield this.execute(msg);
|
|
366
|
-
if (handler) {
|
|
367
|
-
const { subscribed = [] } = destructSubscribeResponse(response);
|
|
368
|
-
subscribed.forEach(channel => this._addSubscription(this.relayProtocol, handler, channel));
|
|
369
|
-
}
|
|
370
|
-
return response;
|
|
371
|
-
}
|
|
372
|
-
catch (error) {
|
|
373
|
-
throw error;
|
|
260
|
+
eventChannel = eventChannel.filter(channel => channel && !this._existsSubscription(this.relayProtocol, channel));
|
|
261
|
+
if (!eventChannel.length) {
|
|
262
|
+
return {};
|
|
374
263
|
}
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
vertoUnsubscribe({ nodeId, channels, handler = null }) {
|
|
378
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
379
|
-
const msg = new Unsubscribe({ sessid: this.sessionid, eventChannel: channels });
|
|
264
|
+
const msg = new Subscribe({ sessid: this.sessionid, eventChannel });
|
|
380
265
|
if (nodeId) {
|
|
381
266
|
msg.targetNodeId = nodeId;
|
|
382
267
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
unsubscribed.forEach(channel => this._removeSubscription(this.relayProtocol, channel));
|
|
388
|
-
notSubscribed.forEach(channel => this._removeSubscription(this.relayProtocol, channel));
|
|
389
|
-
}
|
|
390
|
-
return response;
|
|
391
|
-
}
|
|
392
|
-
catch (error) {
|
|
393
|
-
throw error;
|
|
268
|
+
const response = yield this.execute(msg);
|
|
269
|
+
const { unauthorized = [], subscribed = [] } = destructSubscribeResponse(response);
|
|
270
|
+
if (unauthorized.length) {
|
|
271
|
+
unauthorized.forEach(channel => this._removeSubscription(this.relayProtocol, channel));
|
|
394
272
|
}
|
|
273
|
+
subscribed.forEach(channel => this._addSubscription(this.relayProtocol, handler, channel));
|
|
274
|
+
return response;
|
|
395
275
|
});
|
|
396
276
|
}
|
|
397
|
-
|
|
398
|
-
const msg = new Execute({
|
|
399
|
-
protocol: this.relayProtocol,
|
|
400
|
-
method: 'conference.list',
|
|
401
|
-
params: {}
|
|
402
|
-
});
|
|
403
|
-
console.debug('Send confList', msg);
|
|
404
|
-
return this.execute(msg);
|
|
405
|
-
}
|
|
406
|
-
vertoConferenceList(params) {
|
|
277
|
+
vertoUnsubscribe({ nodeId, channels: eventChannel = [] }) {
|
|
407
278
|
return __awaiter(this, void 0, void 0, function* () {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
command: 'conference',
|
|
412
|
-
data: Object.assign({ command: 'list' }, params),
|
|
413
|
-
});
|
|
414
|
-
response.conferences.forEach((conf) => {
|
|
415
|
-
const { conferenceState, members = [], layouts = [] } = conf;
|
|
416
|
-
const room = destructConferenceState(conferenceState);
|
|
417
|
-
if (members.length) {
|
|
418
|
-
room.members = members.filter(({ type }) => type === 'caller')
|
|
419
|
-
.map((_a) => {
|
|
420
|
-
var { id, uuid, caller_id_number, caller_id_name } = _a, rest = __rest(_a, ["id", "uuid", "caller_id_number", "caller_id_name"]);
|
|
421
|
-
return Object.assign({ participantId: Number(id).toString(), callId: uuid, participantNumber: caller_id_number, participantName: caller_id_name }, rest);
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
if (layouts.length) {
|
|
425
|
-
const normal = layouts.filter(({ type }) => type === 'layout');
|
|
426
|
-
const group = layouts.filter(({ type }) => type === 'layoutGroup');
|
|
427
|
-
room.layouts = mungeLayoutList(normal, group);
|
|
428
|
-
}
|
|
429
|
-
rooms.push(room);
|
|
430
|
-
});
|
|
431
|
-
return rooms;
|
|
432
|
-
}
|
|
433
|
-
catch (error) {
|
|
434
|
-
console.error('vertoConferenceList error', error);
|
|
435
|
-
return [];
|
|
279
|
+
eventChannel = eventChannel.filter(channel => channel && this._existsSubscription(this.relayProtocol, channel));
|
|
280
|
+
if (!eventChannel.length) {
|
|
281
|
+
return {};
|
|
436
282
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
441
|
-
const { fullList = false } = options;
|
|
442
|
-
try {
|
|
443
|
-
const { layouts: { layouts, groups } } = yield this._jsApi({
|
|
444
|
-
command: 'conference',
|
|
445
|
-
data: {
|
|
446
|
-
command: 'listLayouts',
|
|
447
|
-
},
|
|
448
|
-
});
|
|
449
|
-
const final = mungeLayoutList(layouts, groups)
|
|
450
|
-
.map((layout) => {
|
|
451
|
-
const { id, type } = layout;
|
|
452
|
-
const prefix = type === 'group' ? 'group:' : '';
|
|
453
|
-
return Object.assign(Object.assign({}, layout), { id: `${prefix}${id}` });
|
|
454
|
-
});
|
|
455
|
-
if (fullList) {
|
|
456
|
-
return final;
|
|
457
|
-
}
|
|
458
|
-
return final.filter(layout => !layout.belongsToAGroup);
|
|
459
|
-
}
|
|
460
|
-
catch (error) {
|
|
461
|
-
console.error('vertoLayoutList error', error);
|
|
462
|
-
return [];
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
dispatchConferenceUpdate(params) {
|
|
467
|
-
const notification = Object.assign({ type: Notification.ConferenceUpdate }, params);
|
|
468
|
-
trigger(SwEvent.Notification, notification, this.uuid);
|
|
469
|
-
}
|
|
470
|
-
_jsApi(params = {}) {
|
|
471
|
-
const msg = new JSApi(Object.assign(Object.assign({}, params), { sessid: this.sessionid }));
|
|
472
|
-
return this.execute(msg);
|
|
473
|
-
}
|
|
474
|
-
_wrapInExecute(message) {
|
|
475
|
-
const params = {
|
|
476
|
-
message: message.request,
|
|
477
|
-
node_id: message.targetNodeId || undefined
|
|
478
|
-
};
|
|
479
|
-
return new Execute({ protocol: this.relayProtocol, method: 'message', params });
|
|
480
|
-
}
|
|
481
|
-
execute(message) {
|
|
482
|
-
if (message instanceof BaseRequest) {
|
|
483
|
-
message = this._wrapInExecute(message);
|
|
484
|
-
}
|
|
485
|
-
return super.execute(message);
|
|
486
|
-
}
|
|
487
|
-
_onSocketOpen() {
|
|
488
|
-
const _super = Object.create(null, {
|
|
489
|
-
_onSocketOpen: { get: () => super._onSocketOpen }
|
|
490
|
-
});
|
|
491
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
492
|
-
clearTimeout(this._purgeTimeout);
|
|
493
|
-
_super._onSocketOpen.call(this);
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
_onSocketCloseOrError(event) {
|
|
497
|
-
if (this._experimental) {
|
|
498
|
-
const waitFor = 10 * 1000;
|
|
499
|
-
this._purgeTimeout = setTimeout(() => {
|
|
500
|
-
this.purge();
|
|
501
|
-
}, waitFor);
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
this.purge();
|
|
505
|
-
}
|
|
506
|
-
const channels = ['conference-info', 'conference-liveArray', 'conference-mod'];
|
|
507
|
-
this._detachChannels(channels);
|
|
508
|
-
super._onSocketCloseOrError(event);
|
|
509
|
-
}
|
|
510
|
-
vertoSubscribeToConference({ infoChannel, modChannel, laChannel }) {
|
|
511
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
512
|
-
try {
|
|
513
|
-
const channels = [
|
|
514
|
-
infoChannel,
|
|
515
|
-
modChannel,
|
|
516
|
-
laChannel,
|
|
517
|
-
].filter(Boolean);
|
|
518
|
-
if (!(channels === null || channels === void 0 ? void 0 : channels.length)) {
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
this._detachChannels(channels);
|
|
522
|
-
const result = yield this.vertoSubscribe({ channels });
|
|
523
|
-
const { subscribed = [], alreadySubscribed = [] } = destructSubscribeResponse(result);
|
|
524
|
-
const all = subscribed.concat(alreadySubscribed);
|
|
525
|
-
if (all.includes(infoChannel)) {
|
|
526
|
-
this._addSubscription(this.relayProtocol, infoChannelHandler.bind(this, this), infoChannel);
|
|
527
|
-
}
|
|
528
|
-
if (all.includes(modChannel)) {
|
|
529
|
-
this._addSubscription(this.relayProtocol, modChannelHandler.bind(this, this), modChannel);
|
|
530
|
-
}
|
|
531
|
-
if (all.includes(laChannel)) {
|
|
532
|
-
this._addSubscription(this.relayProtocol, laChannelHandler.bind(this, this), laChannel);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
catch (error) {
|
|
536
|
-
console.error('vertoSubscribeToConference error', error);
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
vertoUnsubscribeFromConference({ infoChannel, modChannel, laChannel }) {
|
|
541
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
542
|
-
try {
|
|
543
|
-
const channels = [
|
|
544
|
-
infoChannel,
|
|
545
|
-
modChannel,
|
|
546
|
-
laChannel,
|
|
547
|
-
].filter(Boolean);
|
|
548
|
-
if (!(channels === null || channels === void 0 ? void 0 : channels.length)) {
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
this._detachChannels(channels);
|
|
552
|
-
yield this.vertoUnsubscribe({
|
|
553
|
-
nodeId: this.nodeid,
|
|
554
|
-
channels
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
catch (error) {
|
|
558
|
-
console.error('vertoUnsubscribeFromConference error', error);
|
|
283
|
+
const msg = new Unsubscribe({ sessid: this.sessionid, eventChannel });
|
|
284
|
+
if (nodeId) {
|
|
285
|
+
msg.targetNodeId = nodeId;
|
|
559
286
|
}
|
|
287
|
+
const response = yield this.execute(msg);
|
|
288
|
+
const { unsubscribed = [], notSubscribed = [] } = destructSubscribeResponse(response);
|
|
289
|
+
unsubscribed.forEach(channel => this._removeSubscription(this.relayProtocol, channel));
|
|
290
|
+
notSubscribed.forEach(channel => this._removeSubscription(this.relayProtocol, channel));
|
|
291
|
+
return response;
|
|
560
292
|
});
|
|
561
293
|
}
|
|
562
294
|
}
|
|
@@ -29,13 +29,4 @@ declare class Subscribe extends BaseRequest {
|
|
|
29
29
|
declare class Unsubscribe extends BaseRequest {
|
|
30
30
|
toString(): VertoMethod;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
toString(): VertoMethod;
|
|
34
|
-
}
|
|
35
|
-
declare class Stats extends BaseRequest {
|
|
36
|
-
toString(): VertoMethod;
|
|
37
|
-
}
|
|
38
|
-
declare class Ping extends BaseRequest {
|
|
39
|
-
toString(): VertoMethod;
|
|
40
|
-
}
|
|
41
|
-
export { Login, Invite, Answer, Attach, Bye, Modify, Info, Broadcast, Subscribe, Unsubscribe, Result, JSApi, Stats, Ping, };
|
|
32
|
+
export { Login, Invite, Answer, Attach, Bye, Modify, Info, Broadcast, Subscribe, Unsubscribe, Result };
|
|
@@ -47,19 +47,4 @@ class Unsubscribe extends BaseRequest {
|
|
|
47
47
|
return VertoMethod.Unsubscribe;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
toString() {
|
|
52
|
-
return VertoMethod.JsApi;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
class Stats extends BaseRequest {
|
|
56
|
-
toString() {
|
|
57
|
-
return VertoMethod.Stats;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
class Ping extends BaseRequest {
|
|
61
|
-
toString() {
|
|
62
|
-
return VertoMethod.Ping;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export { Login, Invite, Answer, Attach, Bye, Modify, Info, Broadcast, Subscribe, Unsubscribe, Result, JSApi, Stats, Ping, };
|
|
50
|
+
export { Login, Invite, Answer, Attach, Bye, Modify, Info, Broadcast, Subscribe, Unsubscribe, Result };
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import BaseRequest from './BaseRequest';
|
|
2
|
-
declare type LoginOptions = {
|
|
3
|
-
login: string;
|
|
4
|
-
passwd: string;
|
|
5
|
-
sessionid?: string;
|
|
6
|
-
userVariables?: {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
};
|
|
9
|
-
loginParams?: {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
};
|
|
12
|
-
callIds?: string[];
|
|
13
|
-
};
|
|
14
2
|
declare class Login extends BaseRequest {
|
|
15
3
|
method: string;
|
|
16
|
-
constructor(
|
|
4
|
+
constructor(login: string, passwd: string, sessionid: string, userVariables?: Object);
|
|
17
5
|
}
|
|
18
6
|
export { Login };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import BaseRequest from './BaseRequest';
|
|
2
2
|
class Login extends BaseRequest {
|
|
3
|
-
constructor(
|
|
3
|
+
constructor(login, passwd, sessionid, userVariables = {}) {
|
|
4
4
|
super();
|
|
5
5
|
this.method = 'login';
|
|
6
|
-
const params = { login, passwd, userVariables, loginParams };
|
|
6
|
+
const params = { login, passwd, userVariables, loginParams: {} };
|
|
7
7
|
if (sessionid) {
|
|
8
8
|
params.sessid = sessionid;
|
|
9
9
|
}
|
|
10
|
-
if (callIds === null || callIds === void 0 ? void 0 : callIds.length) {
|
|
11
|
-
params.callIds = callIds;
|
|
12
|
-
}
|
|
13
10
|
this.buildRequest({ method: this.method, params });
|
|
14
11
|
}
|
|
15
12
|
}
|
|
@@ -9,8 +9,9 @@ export default (session, broadcastParams) => {
|
|
|
9
9
|
switch (event) {
|
|
10
10
|
case 'queuing.relay.events':
|
|
11
11
|
if (event_type === 'webrtc.message') {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const handler = new VertoHandler(session);
|
|
13
|
+
handler.nodeId = node_id;
|
|
14
|
+
handler.handleMessage(params.params);
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
16
17
|
session.calling.notificationHandler(params);
|
|
@@ -5,8 +5,8 @@ export default class Connection {
|
|
|
5
5
|
private _wsClient;
|
|
6
6
|
private _host;
|
|
7
7
|
private _timers;
|
|
8
|
-
upDur: number;
|
|
9
|
-
downDur: number;
|
|
8
|
+
upDur: number | null;
|
|
9
|
+
downDur: number | null;
|
|
10
10
|
constructor(session: BaseSession);
|
|
11
11
|
get connected(): boolean;
|
|
12
12
|
get connecting(): boolean;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
declare const isQueued: (
|
|
2
|
-
declare const queueLength: (
|
|
3
|
-
declare const register: (
|
|
4
|
-
declare const registerOnce: (
|
|
5
|
-
declare const deRegister: (
|
|
6
|
-
declare const trigger: (
|
|
7
|
-
declare const deRegisterAll: (
|
|
8
|
-
|
|
9
|
-
export { trigger, register, registerOnce, deRegister, deRegisterAll, isQueued, queueLength, clearQueue };
|
|
1
|
+
declare const isQueued: (eventName: string, uniqueId?: string) => boolean;
|
|
2
|
+
declare const queueLength: (eventName: string, uniqueId?: string) => number;
|
|
3
|
+
declare const register: (eventName: string, callback: Function, uniqueId?: string) => void;
|
|
4
|
+
declare const registerOnce: (eventName: string, callback: Function, uniqueId?: string) => void;
|
|
5
|
+
declare const deRegister: (eventName: string, callback?: Function | null, uniqueId?: string) => boolean;
|
|
6
|
+
declare const trigger: (eventName: string, data: any, uniqueId?: string, globalPropagation?: boolean) => boolean;
|
|
7
|
+
declare const deRegisterAll: (eventName: string) => void;
|
|
8
|
+
export { trigger, register, registerOnce, deRegister, deRegisterAll, isQueued, queueLength };
|