@voicenter-team/opensips-js 1.0.20 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
package/build/index.js CHANGED
@@ -12,13 +12,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const jssip_1 = __importDefault(require("jssip"));
16
15
  const UA_1 = __importDefault(require("./helpers/UA"));
17
16
  const p_iteration_1 = require("p-iteration");
18
17
  const time_helper_1 = require("./helpers/time.helper");
19
18
  const filter_helper_1 = require("./helpers/filter.helper");
20
19
  const audio_helper_1 = require("./helpers/audio.helper");
21
20
  const metrics_1 = __importDefault(require("./helpers/webrtcmetrics/metrics"));
21
+ const JsSIP_1 = __importDefault(require("jssip/lib/JsSIP"));
22
22
  const metric_keys_to_include_1 = require("./enum/metric.keys.to.include");
23
23
  const call_event_listener_type_1 = require("./enum/call.event.listener.type");
24
24
  const CALL_STATUS_UNANSWERED = 0;
@@ -27,41 +27,50 @@ const STORAGE_KEYS = {
27
27
  SELECTED_OUTPUT_DEVICE: 'selectedOutputDevice'
28
28
  };
29
29
  class OpenSIPSJS extends UA_1.default {
30
- constructor(options) {
31
- const configuration = Object.assign(Object.assign({}, options.configuration), { sockets: options.socketInterfaces.map(sock => new jssip_1.default.WebSocketInterface(sock)) });
30
+ constructor(options, logger) {
31
+ const configuration = Object.assign(Object.assign({}, options.configuration), { sockets: options.socketInterfaces.map(sock => new JsSIP_1.default.WebSocketInterface(sock)) });
32
32
  super(configuration);
33
33
  this.initialized = false;
34
+ this.logger = console;
35
+ /* Events */
34
36
  this.newRTCSessionEventName = 'newRTCSession';
35
37
  this.registeredEventName = 'registered';
36
38
  this.unregisteredEventName = 'unregistered';
39
+ this.disconnectedEventName = 'disconnected';
40
+ this.connectedEventName = 'connected';
41
+ this.newMSRPSessionEventName = 'newMSRPSession';
42
+ /* State */
43
+ this.muted = false;
44
+ this.isAutoAnswer = false;
45
+ this.isDNDEnabled = false;
46
+ this.muteWhenJoinEnabled = false;
47
+ this.activeRooms = {};
37
48
  this.activeCalls = {};
38
49
  this.extendedCalls = {};
39
- this.state = {
40
- isMuted: false,
41
- isAutoAnswer: false,
42
- activeCalls: {},
43
- extendedCalls: {},
44
- availableMediaDevices: [],
45
- selectedMediaDevices: {
46
- input: 'default',
47
- output: 'default' //localStorage.getItem(STORAGE_KEYS.SELECTED_OUTPUT_DEVICE) || 'default'
48
- },
49
- microphoneInputLevel: 2,
50
- speakerVolume: 1,
51
- muteWhenJoin: false,
52
- originalStream: null,
53
- isDND: false,
54
- listeners: {},
55
- activeRooms: {},
56
- callStatus: {},
57
- callTime: {},
58
- timeIntervals: {},
59
- callMetrics: {},
60
- metricConfig: {
61
- refreshEvery: 1000,
62
- }
50
+ this.activeMessages = {};
51
+ this.extendedMessages = {};
52
+ this.msrpHistory = {};
53
+ this.microphoneInputLevelValue = 2; // [0;2]
54
+ this.speakerVolumeValue = 1; // [0;1]
55
+ this.availableMediaDevices = [];
56
+ this.selectedMediaDevices = {
57
+ input: 'default',
58
+ output: 'default'
63
59
  };
60
+ this.callStatus = {};
61
+ this.callTime = {};
62
+ this.callMetrics = {};
63
+ this.timeIntervals = {};
64
+ this.metricConfig = {
65
+ refreshEvery: 1000
66
+ };
67
+ this.originalStreamValue = null;
68
+ this.isReconnecting = false;
69
+ this.listenersList = {};
64
70
  this.options = options;
71
+ if (logger && (0, audio_helper_1.isLoggerCompatible)(logger)) {
72
+ this.logger = logger;
73
+ }
65
74
  }
66
75
  on(type, listener) {
67
76
  return super.on(type, listener);
@@ -80,78 +89,57 @@ class OpenSIPSJS extends UA_1.default {
80
89
  return options;
81
90
  }
82
91
  get currentActiveRoomId() {
83
- return this._currentActiveRoomId;
92
+ return this.currentActiveRoomIdValue;
84
93
  }
85
94
  set currentActiveRoomId(roomId) {
86
- this._currentActiveRoomId = roomId;
95
+ this.currentActiveRoomIdValue = roomId;
87
96
  this.emit('currentActiveRoomChanged', roomId);
88
97
  }
89
98
  get autoAnswer() {
90
- return this.state.isAutoAnswer;
91
- }
92
- set autoAnswer(value) {
93
- this.state.isAutoAnswer = value;
99
+ return this.isAutoAnswer;
94
100
  }
95
101
  get callAddingInProgress() {
96
- return this._callAddingInProgress;
102
+ return this.isCallAddingInProgress;
97
103
  }
98
104
  set callAddingInProgress(value) {
99
- this._callAddingInProgress = value;
105
+ this.isCallAddingInProgress = value;
100
106
  this.emit('callAddingInProgressChanged', value);
101
107
  }
102
- get muteWhenJoin() {
103
- return this.state.muteWhenJoin;
108
+ get isMSRPInitializing() {
109
+ return this.isMSRPInitializingValue;
104
110
  }
105
- set muteWhenJoin(value) {
106
- this.state.muteWhenJoin = value;
107
- this.emit('changeMuteWhenJoin', value);
111
+ get muteWhenJoin() {
112
+ return this.muteWhenJoinEnabled;
108
113
  }
109
114
  get isDND() {
110
- return this.state.isDND;
111
- }
112
- set isDND(value) {
113
- this.state.isDND = value;
114
- this.emit('changeIsDND', value);
115
+ return this.isDNDEnabled;
115
116
  }
116
117
  get speakerVolume() {
117
- return this.state.speakerVolume;
118
- }
119
- set speakerVolume(value) {
120
- this.state.speakerVolume = value;
121
- Object.values(this.state.extendedCalls).forEach((call) => {
122
- if (call.audioTag) {
123
- call.audioTag.volume = value;
124
- }
125
- });
118
+ return this.speakerVolumeValue;
126
119
  }
127
120
  get microphoneInputLevel() {
128
- return this.state.microphoneInputLevel;
129
- }
130
- set microphoneInputLevel(value) {
131
- this.state.microphoneInputLevel = value;
132
- this.roomReconfigure(this.currentActiveRoomId);
121
+ return this.microphoneInputLevelValue;
133
122
  }
134
123
  get getActiveCalls() {
135
- return this.state.activeCalls;
124
+ return this.activeCalls;
136
125
  }
137
126
  get hasActiveCalls() {
138
- return Object.values(this.state.extendedCalls).length > 0;
127
+ return Object.values(this.extendedCalls).length > 0;
128
+ }
129
+ get getActiveMessages() {
130
+ return this.activeMessages;
139
131
  }
140
132
  get getActiveRooms() {
141
- return this.state.activeRooms;
133
+ return this.activeRooms;
142
134
  }
143
135
  get isMuted() {
144
- return this.state.isMuted;
145
- }
146
- set isMuted(value) {
147
- this.state.isMuted = value;
148
- this.emit('changeIsMuted', value);
136
+ return this.muted;
149
137
  }
150
138
  get getInputDeviceList() {
151
- return this.state.availableMediaDevices.filter(device => device.kind === 'audioinput');
139
+ return this.availableMediaDevices.filter(device => device.kind === 'audioinput');
152
140
  }
153
141
  get getOutputDeviceList() {
154
- return this.state.availableMediaDevices.filter(device => device.kind === 'audiooutput');
142
+ return this.availableMediaDevices.filter(device => device.kind === 'audiooutput');
155
143
  }
156
144
  /*getInputDeviceList: (state) => {
157
145
  return state.availableMediaDevices.filter(device => device.kind === 'audioinput');
@@ -163,7 +151,7 @@ class OpenSIPSJS extends UA_1.default {
163
151
  return {
164
152
  audio: {
165
153
  deviceId: {
166
- exact: this.state.selectedMediaDevices.input
154
+ exact: this.selectedMediaDevices.input
167
155
  }
168
156
  },
169
157
  video: false
@@ -176,26 +164,16 @@ class OpenSIPSJS extends UA_1.default {
176
164
  return this.getOutputDeviceList.find(device => device.deviceId === 'default');
177
165
  }
178
166
  get selectedInputDevice() {
179
- return this.state.selectedMediaDevices.input;
180
- }
181
- set selectedInputDevice(deviceId) {
182
- localStorage.setItem(STORAGE_KEYS.SELECTED_INPUT_DEVICE, deviceId);
183
- this.state.selectedMediaDevices.input = deviceId;
184
- this.emit('changeActiveInputMediaDevice', deviceId);
167
+ return this.selectedMediaDevices.input;
185
168
  }
186
169
  get selectedOutputDevice() {
187
- return this.state.selectedMediaDevices.output;
188
- }
189
- set selectedOutputDevice(deviceId) {
190
- localStorage.setItem(STORAGE_KEYS.SELECTED_OUTPUT_DEVICE, deviceId);
191
- this.state.selectedMediaDevices.output = deviceId;
192
- this.emit('changeActiveOutputMediaDevice', deviceId);
170
+ return this.selectedMediaDevices.output;
193
171
  }
194
172
  get originalStream() {
195
- return this.state.originalStream;
173
+ return this.originalStreamValue;
196
174
  }
197
175
  setAvailableMediaDevices(devices) {
198
- this.state.availableMediaDevices = devices;
176
+ this.availableMediaDevices = devices;
199
177
  this.emit('changeAvailableDeviceList', devices);
200
178
  }
201
179
  updateDeviceList() {
@@ -208,8 +186,8 @@ class OpenSIPSJS extends UA_1.default {
208
186
  setMediaDevices(setDefaults = false) {
209
187
  var _a, _b;
210
188
  return __awaiter(this, void 0, void 0, function* () {
211
- this.state.selectedMediaDevices.input = localStorage.getItem(STORAGE_KEYS.SELECTED_INPUT_DEVICE) || 'default';
212
- this.state.selectedMediaDevices.output = localStorage.getItem(STORAGE_KEYS.SELECTED_OUTPUT_DEVICE) || 'default';
189
+ this.selectedMediaDevices.input = localStorage.getItem(STORAGE_KEYS.SELECTED_INPUT_DEVICE) || 'default';
190
+ this.selectedMediaDevices.output = localStorage.getItem(STORAGE_KEYS.SELECTED_OUTPUT_DEVICE) || 'default';
213
191
  yield navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);
214
192
  const devices = yield navigator.mediaDevices.enumerateDevices();
215
193
  this.setAvailableMediaDevices(devices);
@@ -226,47 +204,51 @@ class OpenSIPSJS extends UA_1.default {
226
204
  setCallTime(value) {
227
205
  const time = Object.assign({}, value);
228
206
  delete time.callId;
229
- this.state.callTime = Object.assign(Object.assign({}, this.state.callTime), { [value.callId]: time });
207
+ this.callTime = Object.assign(Object.assign({}, this.callTime), { [value.callId]: time });
208
+ this.emit('changeCallTime', this.callTime);
230
209
  }
231
210
  removeCallTime(callId) {
232
- const callTimeCopy = Object.assign({}, this.state.callTime);
211
+ const callTimeCopy = Object.assign({}, this.callTime);
233
212
  delete callTimeCopy[callId];
234
- this.state.callTime = Object.assign({}, callTimeCopy);
213
+ this.callTime = Object.assign({}, callTimeCopy);
214
+ this.emit('changeCallTime', this.callTime);
235
215
  }
236
216
  setTimeInterval(callId, interval) {
237
- this.state.timeIntervals = Object.assign(Object.assign({}, this.state.timeIntervals), { [callId]: interval });
217
+ this.timeIntervals = Object.assign(Object.assign({}, this.timeIntervals), { [callId]: interval });
238
218
  }
239
219
  removeTimeInterval(callId) {
240
- const timeIntervalsCopy = Object.assign({}, this.state.timeIntervals);
220
+ const timeIntervalsCopy = Object.assign({}, this.timeIntervals);
241
221
  clearInterval(timeIntervalsCopy[callId]);
242
222
  delete timeIntervalsCopy[callId];
243
- this.state.timeIntervals = Object.assign({}, timeIntervalsCopy);
223
+ this.timeIntervals = Object.assign({}, timeIntervalsCopy);
244
224
  }
245
225
  _stopCallTimer(callId) {
246
226
  this.removeTimeInterval(callId);
247
227
  this.removeCallTime(callId);
248
228
  }
249
229
  setMetricsConfig(config) {
250
- this.state.metricConfig = Object.assign(Object.assign({}, this.state.metricConfig), config);
230
+ this.metricConfig = Object.assign(Object.assign({}, this.metricConfig), config);
251
231
  }
252
232
  sendDTMF(callId, value) {
253
233
  const validation_regex = /^[A-D0-9]+$/g;
254
234
  if (!validation_regex.test(value)) {
255
235
  throw new Error('Not allowed character in DTMF input');
256
236
  }
257
- const call = this.state.extendedCalls[callId];
237
+ const call = this.extendedCalls[callId];
258
238
  call.sendDTMF(value);
259
239
  }
240
+ setIsMuted(value) {
241
+ this.muted = value;
242
+ this.emit('changeIsMuted', value);
243
+ }
260
244
  doMute(value) {
261
245
  const activeRoomId = this.currentActiveRoomId;
262
- this.isMuted = value;
246
+ this.setIsMuted(value);
247
+ //this.isMuted = value
263
248
  this.roomReconfigure(activeRoomId);
264
249
  }
265
- sendMessage(target, body, options) {
266
- return super.sendMessage(`sip:${target}@${this.sipDomain}`, body, options);
267
- }
268
250
  doCallHold({ callId, toHold, automatic }) {
269
- const call = this.state.extendedCalls[callId];
251
+ const call = this.extendedCalls[callId];
270
252
  call._automaticHold = automatic !== null && automatic !== void 0 ? automatic : false;
271
253
  if (toHold) {
272
254
  call.hold();
@@ -282,7 +264,7 @@ class OpenSIPSJS extends UA_1.default {
282
264
  }).forEach(call => this.callTerminate(call._id));
283
265
  }
284
266
  callAnswer(callId) {
285
- const call = this.state.extendedCalls[callId];
267
+ const call = this.extendedCalls[callId];
286
268
  this._cancelAllOutgoingUnanswered();
287
269
  call.answer(this.sipOptions);
288
270
  this.updateCall(call);
@@ -292,6 +274,14 @@ class OpenSIPSJS extends UA_1.default {
292
274
  this._triggerAddStream(event, call);
293
275
  }));
294
276
  }
277
+ msrpAnswer(callId) {
278
+ const call = this.extendedMessages[callId];
279
+ //this._cancelAllOutgoingUnanswered()
280
+ call.answer(this.sipOptions);
281
+ this.updateMSRPSession(call);
282
+ // TODO: maybe would be better to move to the top
283
+ //this.setCurrentActiveRoomId(call.roomId)
284
+ }
295
285
  callMove(callId, roomId) {
296
286
  return __awaiter(this, void 0, void 0, function* () {
297
287
  this._updateCallStatus({ callId, isMoving: true });
@@ -300,14 +290,18 @@ class OpenSIPSJS extends UA_1.default {
300
290
  });
301
291
  }
302
292
  updateCall(value) {
303
- this.state.activeCalls[value._id] = (0, audio_helper_1.simplifyCallObject)(value);
304
- this.emit('changeActiveCalls', this.state.activeCalls);
293
+ this.activeCalls[value._id] = (0, audio_helper_1.simplifyCallObject)(value);
294
+ this.emit('changeActiveCalls', this.activeCalls);
295
+ }
296
+ updateMSRPSession(value) {
297
+ this.activeMessages[value._id] = (0, audio_helper_1.simplifyMessageObject)(value);
298
+ this.emit('changeActiveMessages', this.activeMessages);
305
299
  }
306
300
  updateRoom(value) {
307
- const room = this.state.activeRooms[value.roomId];
301
+ const room = this.activeRooms[value.roomId];
308
302
  const newRoomData = Object.assign(Object.assign({}, room), value);
309
- this.state.activeRooms = Object.assign(Object.assign({}, this.state.activeRooms), { [value.roomId]: Object.assign({}, newRoomData) });
310
- this.emit('updateRoom', { room: newRoomData, roomList: this.state.activeRooms });
303
+ this.activeRooms = Object.assign(Object.assign({}, this.activeRooms), { [value.roomId]: Object.assign({}, newRoomData) });
304
+ this.emit('updateRoom', { room: newRoomData, roomList: this.activeRooms });
311
305
  }
312
306
  hasAutoAnswerHeaders(event) {
313
307
  const regex = /answer-after=0/;
@@ -316,26 +310,37 @@ class OpenSIPSJS extends UA_1.default {
316
310
  return callInfoHeader && regex.test(callInfoHeader);
317
311
  }
318
312
  _addCall(value, emitEvent = true) {
319
- this.state.activeCalls = Object.assign(Object.assign({}, this.state.activeCalls), { [value._id]: (0, audio_helper_1.simplifyCallObject)(value) });
320
- /*this.state.extendedCalls = {
321
- ...this.state.extendedCalls,
313
+ this.activeCalls = Object.assign(Object.assign({}, this.activeCalls), { [value._id]: (0, audio_helper_1.simplifyCallObject)(value) });
314
+ /*this.extendedCalls = {
315
+ ...this.extendedCalls,
322
316
  [value._id]: value
323
317
  }*/
324
- this.state.extendedCalls[value._id] = value;
318
+ this.extendedCalls[value._id] = value;
325
319
  if (emitEvent) {
326
- this.emit('changeActiveCalls', this.state.activeCalls);
320
+ this.emit('changeActiveCalls', this.activeCalls);
327
321
  }
328
322
  }
329
323
  _addCallStatus(callId) {
330
- this.state.callStatus = Object.assign(Object.assign({}, this.state.callStatus), { [callId]: {
324
+ this.callStatus = Object.assign(Object.assign({}, this.callStatus), { [callId]: {
331
325
  isMoving: false,
332
326
  isTransferring: false,
333
327
  isMerging: false
334
328
  } });
335
- this.emit('changeCallStatus', this.state.callStatus);
329
+ this.emit('changeCallStatus', this.callStatus);
330
+ }
331
+ _addMMSRPSession(value) {
332
+ this.activeMessages = Object.assign(Object.assign({}, this.activeMessages), { [value._id]: (0, audio_helper_1.simplifyMessageObject)(value) });
333
+ this.extendedMessages[value._id] = value;
334
+ this.emit('changeActiveMessages', this.activeMessages);
335
+ }
336
+ _addMSRPMessage(value, session) {
337
+ const sessionMessages = this.msrpHistory[session.id] || [];
338
+ sessionMessages.push(value);
339
+ this.msrpHistory = Object.assign(Object.assign({}, this.msrpHistory), { [session.id]: [...sessionMessages] });
340
+ this.emit('newMSRPMessage', { message: value, session: session });
336
341
  }
337
342
  _updateCallStatus(value) {
338
- const prevStatus = Object.assign({}, this.state.callStatus[value.callId]);
343
+ const prevStatus = Object.assign({}, this.callStatus[value.callId]);
339
344
  const newStatus = Object.assign({}, prevStatus);
340
345
  if (value.isMoving !== undefined) {
341
346
  newStatus.isMoving = value.isMoving;
@@ -346,25 +351,25 @@ class OpenSIPSJS extends UA_1.default {
346
351
  if (value.isMerging !== undefined) {
347
352
  newStatus.isMerging = value.isMerging;
348
353
  }
349
- this.state.callStatus = Object.assign(Object.assign({}, this.state.callStatus), { [value.callId]: Object.assign({}, newStatus) });
350
- this.emit('changeCallStatus', this.state.callStatus);
354
+ this.callStatus = Object.assign(Object.assign({}, this.callStatus), { [value.callId]: Object.assign({}, newStatus) });
355
+ this.emit('changeCallStatus', this.callStatus);
351
356
  }
352
357
  _removeCallStatus(callId) {
353
- const callStatusCopy = Object.assign({}, this.state.callStatus);
358
+ const callStatusCopy = Object.assign({}, this.callStatus);
354
359
  delete callStatusCopy[callId];
355
- this.state.callStatus = Object.assign({}, callStatusCopy);
356
- this.emit('changeCallStatus', this.state.callStatus);
360
+ this.callStatus = Object.assign({}, callStatusCopy);
361
+ this.emit('changeCallStatus', this.callStatus);
357
362
  }
358
363
  _addRoom(value) {
359
- this.state.activeRooms = Object.assign(Object.assign({}, this.state.activeRooms), { [value.roomId]: value });
360
- this.emit('addRoom', { room: value, roomList: this.state.activeRooms });
364
+ this.activeRooms = Object.assign(Object.assign({}, this.activeRooms), { [value.roomId]: value });
365
+ this.emit('addRoom', { room: value, roomList: this.activeRooms });
361
366
  }
362
367
  setMicrophone(dId) {
363
368
  return __awaiter(this, void 0, void 0, function* () {
364
369
  if (!this.getInputDeviceList.find(({ deviceId }) => deviceId === dId)) {
365
370
  return;
366
371
  }
367
- this.selectedInputDevice = dId;
372
+ this.setSelectedInputDevice(dId);
368
373
  let stream; // = null
369
374
  try {
370
375
  stream = yield navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);
@@ -375,7 +380,7 @@ class OpenSIPSJS extends UA_1.default {
375
380
  if (Object.keys(this.getActiveCalls).length === 0) {
376
381
  return;
377
382
  }
378
- const callsInCurrentRoom = Object.values(this.state.extendedCalls).filter(call => call.roomId === this.currentActiveRoomId);
383
+ const callsInCurrentRoom = Object.values(this.extendedCalls).filter(call => call.roomId === this.currentActiveRoomId);
379
384
  if (callsInCurrentRoom.length === 1) {
380
385
  Object.values(callsInCurrentRoom).forEach(call => {
381
386
  const processedStream = (0, audio_helper_1.processAudioVolume)(stream, this.microphoneInputLevel);
@@ -391,7 +396,7 @@ class OpenSIPSJS extends UA_1.default {
391
396
  });
392
397
  }
393
398
  _setOriginalStream(value) {
394
- this.state.originalStream = value;
399
+ this.originalStreamValue = value;
395
400
  this.emit('changeOriginalStream', value);
396
401
  }
397
402
  setSpeaker(dId) {
@@ -399,8 +404,8 @@ class OpenSIPSJS extends UA_1.default {
399
404
  if (!this.getOutputDeviceList.find(({ deviceId }) => deviceId === dId)) {
400
405
  return;
401
406
  }
402
- this.selectedOutputDevice = dId;
403
- const activeCallList = Object.values(this.state.extendedCalls);
407
+ this.setSelectedOutputDevice(dId);
408
+ const activeCallList = Object.values(this.extendedCalls);
404
409
  if (activeCallList.length === 0) {
405
410
  return;
406
411
  }
@@ -418,17 +423,17 @@ class OpenSIPSJS extends UA_1.default {
418
423
  });
419
424
  }
420
425
  removeRoom(roomId) {
421
- const activeRoomsCopy = Object.assign({}, this.state.activeRooms);
426
+ const activeRoomsCopy = Object.assign({}, this.activeRooms);
422
427
  const roomToRemove = Object.assign({}, activeRoomsCopy[roomId]);
423
428
  delete activeRoomsCopy[roomId];
424
- this.state.activeRooms = Object.assign({}, activeRoomsCopy);
425
- this.emit('removeRoom', { room: roomToRemove, roomList: this.state.activeRooms });
429
+ this.activeRooms = Object.assign({}, activeRoomsCopy);
430
+ this.emit('removeRoom', { room: roomToRemove, roomList: this.activeRooms });
426
431
  }
427
432
  deleteRoomIfEmpty(roomId) {
428
433
  if (roomId === undefined) {
429
434
  return;
430
435
  }
431
- if (Object.values(this.state.extendedCalls).filter(call => call.roomId === roomId).length === 0) {
436
+ if (Object.values(this.extendedCalls).filter(call => call.roomId === roomId).length === 0) {
432
437
  this.removeRoom(roomId);
433
438
  if (this.currentActiveRoomId === roomId) {
434
439
  this.currentActiveRoomId = undefined;
@@ -441,7 +446,7 @@ class OpenSIPSJS extends UA_1.default {
441
446
  }
442
447
  }
443
448
  muteReconfigure(call) {
444
- if (this.state.isMuted) {
449
+ if (this.muted) {
445
450
  call.mute({ audio: true });
446
451
  }
447
452
  else {
@@ -453,7 +458,7 @@ class OpenSIPSJS extends UA_1.default {
453
458
  if (roomId === undefined) {
454
459
  return;
455
460
  }
456
- const callsInRoom = Object.values(this.state.extendedCalls).filter(call => call.roomId === roomId);
461
+ const callsInRoom = Object.values(this.extendedCalls).filter(call => call.roomId === roomId);
457
462
  // Let`s take care on the audio output first and check if passed room is our selected room
458
463
  if (this.currentActiveRoomId === roomId) {
459
464
  callsInRoom.forEach(call => {
@@ -494,7 +499,7 @@ class OpenSIPSJS extends UA_1.default {
494
499
  }
495
500
  if (stream && callsInRoom[0].connection && callsInRoom[0].connection.getSenders()[0]) {
496
501
  const processedStream = (0, audio_helper_1.processAudioVolume)(stream, this.microphoneInputLevel);
497
- processedStream.getTracks().forEach(track => track.enabled = !this.state.isMuted);
502
+ processedStream.getTracks().forEach(track => track.enabled = !this.muted);
498
503
  this._setOriginalStream(processedStream);
499
504
  yield callsInRoom[0].connection.getSenders()[0].replaceTrack(processedStream.getTracks()[0]);
500
505
  this.muteReconfigure(callsInRoom[0]);
@@ -566,7 +571,7 @@ class OpenSIPSJS extends UA_1.default {
566
571
  }
567
572
  }
568
573
  muteCaller(callId, value) {
569
- const call = this.state.extendedCalls[callId];
574
+ const call = this.extendedCalls[callId];
570
575
  if (call && call.connection.getReceivers().length) {
571
576
  call.localMuted = value;
572
577
  call.connection.getReceivers().forEach((receiver) => {
@@ -577,7 +582,13 @@ class OpenSIPSJS extends UA_1.default {
577
582
  }
578
583
  }
579
584
  callTerminate(callId) {
580
- const call = this.state.extendedCalls[callId];
585
+ const call = this.extendedCalls[callId];
586
+ if (call._status !== 8) {
587
+ call.terminate();
588
+ }
589
+ }
590
+ messageTerminate(callId) {
591
+ const call = this.extendedMessages[callId];
581
592
  if (call._status !== 8) {
582
593
  call.terminate();
583
594
  }
@@ -586,7 +597,7 @@ class OpenSIPSJS extends UA_1.default {
586
597
  if (target.toString().length === 0) {
587
598
  return console.error('Target must be passed');
588
599
  }
589
- const call = this.state.extendedCalls[callId];
600
+ const call = this.extendedCalls[callId];
590
601
  if (!call._is_confirmed && !call._is_canceled) {
591
602
  const redirectTarget = `sip:${target}@${this.sipDomain}`;
592
603
  call.terminate({
@@ -601,7 +612,7 @@ class OpenSIPSJS extends UA_1.default {
601
612
  this.updateCall(call);
602
613
  }
603
614
  callMerge(roomId) {
604
- const callsInRoom = Object.values(this.state.extendedCalls).filter((call) => call.roomId === roomId);
615
+ const callsInRoom = Object.values(this.extendedCalls).filter((call) => call.roomId === roomId);
605
616
  if (callsInRoom.length !== 2)
606
617
  return;
607
618
  const firstCall = callsInRoom[0];
@@ -617,7 +628,8 @@ class OpenSIPSJS extends UA_1.default {
617
628
  }
618
629
  // TODO: Use this method in demo
619
630
  setDND(value) {
620
- this.isDND = value;
631
+ this.isDNDEnabled = value;
632
+ this.emit('changeIsDND', value);
621
633
  }
622
634
  _startCallTimer(callId) {
623
635
  const timeData = {
@@ -629,7 +641,7 @@ class OpenSIPSJS extends UA_1.default {
629
641
  };
630
642
  this.setCallTime(timeData);
631
643
  const interval = setInterval(() => {
632
- const callTime = Object.assign({}, this.state.callTime[callId]);
644
+ const callTime = Object.assign({}, this.callTime[callId]);
633
645
  const updatedTime = (0, time_helper_1.setupTime)(callTime);
634
646
  this.setCallTime(Object.assign({ callId }, updatedTime));
635
647
  }, 1000);
@@ -647,23 +659,24 @@ class OpenSIPSJS extends UA_1.default {
647
659
  });
648
660
  }
649
661
  getNewRoomId() {
650
- const roomIdList = Object.keys(this.state.activeRooms);
662
+ const roomIdList = Object.keys(this.activeRooms);
651
663
  if (roomIdList.length === 0) {
652
664
  return 1;
653
665
  }
654
666
  return (parseInt(roomIdList.sort()[roomIdList.length - 1]) + 1);
655
667
  }
656
668
  subscribe(type, listener) {
657
- const isListenerEmpty = !this.state.listeners[type] || !this.state.listeners[type].length;
658
- const newListeners = isListenerEmpty ? [listener] : [...this.state.listeners[type], listener];
659
- this.state.listeners = Object.assign(Object.assign({}, this.state.listeners), { [type]: newListeners });
669
+ const isListenerEmpty = !this.listenersList[type] || !this.listenersList[type].length;
670
+ const newListeners = isListenerEmpty ? [listener] : [...this.listenersList[type], listener];
671
+ this.listenersList = Object.assign(Object.assign({}, this.listenersList), { [type]: newListeners });
660
672
  }
661
673
  removeIListener(value) {
662
- const listenersCopy = Object.assign({}, this.state.listeners);
674
+ const listenersCopy = Object.assign({}, this.listenersList);
663
675
  delete listenersCopy[value];
664
- this.state.listeners = Object.assign({}, listenersCopy);
676
+ this.listenersList = Object.assign({}, listenersCopy);
665
677
  }
666
678
  addCall(event) {
679
+ var _a, _b;
667
680
  return __awaiter(this, void 0, void 0, function* () {
668
681
  const session = event.session;
669
682
  const sessionAlreadyInActiveCalls = this.getActiveCalls[session.id];
@@ -677,6 +690,7 @@ class OpenSIPSJS extends UA_1.default {
677
690
  roomId
678
691
  };
679
692
  if (session.direction === 'incoming') {
693
+ this.logger.log('New incoming call from', (_b = (_a = session._remote_identity) === null || _a === void 0 ? void 0 : _a._uri) === null || _b === void 0 ? void 0 : _b._user);
680
694
  newRoomInfo.incomingInProgress = true;
681
695
  this.subscribe(call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_CONFIRMED, (call) => {
682
696
  if (session.id === call.id) {
@@ -720,8 +734,65 @@ class OpenSIPSJS extends UA_1.default {
720
734
  }
721
735
  });
722
736
  }
737
+ addMessageSession(session) {
738
+ // For cases when session.direction === 'outgoing' and all the
739
+ // session properties are missing before answer
740
+ if (!session._id) {
741
+ return;
742
+ }
743
+ const sessionAlreadyInActiveMessages = this.getActiveMessages[session._id];
744
+ if (sessionAlreadyInActiveMessages !== undefined) {
745
+ return;
746
+ }
747
+ /*const roomId = this.getNewRoomId()
748
+
749
+ const newRoomInfo: IRoom = {
750
+ started: new Date(),
751
+ incomingInProgress: false,
752
+ roomId
753
+ }*/
754
+ /*if (session.direction === 'incoming') {
755
+ newRoomInfo.incomingInProgress = true
756
+
757
+ this.subscribe(CALL_EVENT_LISTENER_TYPE.CALL_CONFIRMED, (call) => {
758
+ if (session.id === call.id) {
759
+ this.updateRoom( {
760
+ incomingInProgress: false,
761
+ roomId
762
+ })
763
+ this._startCallTimer(session.id)
764
+ }
765
+ })
766
+
767
+ this.subscribe(CALL_EVENT_LISTENER_TYPE.CALL_FAILED, (call) => {
768
+ if (session.id === call.id) {
769
+ this.updateRoom({
770
+ incomingInProgress: false,
771
+ roomId
772
+ })
773
+ }
774
+ })
775
+
776
+ } else if (session.direction === 'outgoing') {
777
+ this._startCallTimer(session.id)
778
+ }*/
779
+ const MSRPSession = session;
780
+ //MSRPSession.roomId = roomId
781
+ this._addMMSRPSession(MSRPSession);
782
+ //this._addMMSRPSessionStatus(session.id)
783
+ //this._addRoom(newRoomInfo)
784
+ }
723
785
  _triggerListener({ listenerType, session, event }) {
724
- const listeners = this.state.listeners[listenerType];
786
+ const listeners = this.listenersList[listenerType];
787
+ if (!listeners || !listeners.length) {
788
+ return;
789
+ }
790
+ listeners.forEach((listener) => {
791
+ listener(session, event);
792
+ });
793
+ }
794
+ _triggerMSRPListener({ listenerType, session, event }) {
795
+ const listeners = this.listenersList[listenerType];
725
796
  if (!listeners || !listeners.length) {
726
797
  return;
727
798
  }
@@ -730,20 +801,35 @@ class OpenSIPSJS extends UA_1.default {
730
801
  });
731
802
  }
732
803
  _removeCall(value) {
733
- const stateActiveCallsCopy = Object.assign({}, this.state.activeCalls);
804
+ const stateActiveCallsCopy = Object.assign({}, this.activeCalls);
734
805
  delete stateActiveCallsCopy[value];
735
806
  // delete activeCalls[value]
736
- this.state.activeCalls = Object.assign({}, stateActiveCallsCopy);
737
- const stateExtendedCallsCopy = Object.assign({}, this.state.extendedCalls);
807
+ this.activeCalls = Object.assign({}, stateActiveCallsCopy);
808
+ const stateExtendedCallsCopy = Object.assign({}, this.extendedCalls);
738
809
  delete stateExtendedCallsCopy[value];
739
- this.state.extendedCalls = Object.assign({}, stateExtendedCallsCopy);
740
- this.emit('changeActiveCalls', this.state.activeCalls);
810
+ this.extendedCalls = Object.assign({}, stateExtendedCallsCopy);
811
+ this.emit('changeActiveCalls', this.activeCalls);
812
+ }
813
+ _removeMMSRPSession(value) {
814
+ const stateActiveMessagesCopy = Object.assign({}, this.activeMessages);
815
+ delete stateActiveMessagesCopy[value];
816
+ //delete activeMessages[value]
817
+ this.activeMessages = Object.assign({}, stateActiveMessagesCopy);
818
+ const stateExtendedMessagesCopy = Object.assign({}, this.extendedMessages);
819
+ delete stateExtendedMessagesCopy[value];
820
+ this.extendedMessages = Object.assign({}, stateExtendedMessagesCopy);
821
+ this.emit('changeActiveMessages', this.activeMessages);
741
822
  }
742
823
  _activeCallListRemove(call) {
743
- const callRoomIdToConfigure = this.state.extendedCalls[call._id].roomId;
824
+ const callRoomIdToConfigure = this.extendedCalls[call._id].roomId;
744
825
  this._removeCall(call._id);
745
826
  this.roomReconfigure(callRoomIdToConfigure);
746
827
  }
828
+ _activeMessageListRemove(call) {
829
+ //const callRoomIdToConfigure = activeMessages[call._id].roomId
830
+ this._removeMMSRPSession(call._id);
831
+ //this.roomReconfigure(callRoomIdToConfigure)
832
+ }
747
833
  newRTCSessionCallback(event) {
748
834
  const session = event.session;
749
835
  if (this.isDND) {
@@ -752,6 +838,8 @@ class OpenSIPSJS extends UA_1.default {
752
838
  }
753
839
  // stop timers on ended and failed
754
840
  session.on('ended', (event) => {
841
+ var _a, _b;
842
+ this.logger.log('Session ended for', (_b = (_a = session._remote_identity) === null || _a === void 0 ? void 0 : _a._uri) === null || _b === void 0 ? void 0 : _b._user);
755
843
  this._triggerListener({ listenerType: call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_ENDED, session, event });
756
844
  const s = this.getActiveCalls[session.id];
757
845
  if (s) {
@@ -760,14 +848,18 @@ class OpenSIPSJS extends UA_1.default {
760
848
  this._stopCallTimer(session.id);
761
849
  this._removeCallStatus(session.id);
762
850
  this._removeCallMetrics(session.id);
763
- if (!Object.keys(this.state.extendedCalls).length) {
764
- this.isMuted = false;
851
+ if (!Object.keys(this.extendedCalls).length) {
852
+ this.setIsMuted(false);
765
853
  }
766
854
  });
767
855
  session.on('progress', (event) => {
856
+ var _a, _b;
857
+ this.logger.log('Session in progress for', (_b = (_a = session._remote_identity) === null || _a === void 0 ? void 0 : _a._uri) === null || _b === void 0 ? void 0 : _b._user);
768
858
  this._triggerListener({ listenerType: call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_PROGRESS, session, event });
769
859
  });
770
860
  session.on('failed', (event) => {
861
+ var _a, _b;
862
+ this.logger.log('Session failed for', (_b = (_a = session._remote_identity) === null || _a === void 0 ? void 0 : _a._uri) === null || _b === void 0 ? void 0 : _b._user);
771
863
  this._triggerListener({ listenerType: call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_FAILED, session, event });
772
864
  if (session.id === this.callAddingInProgress) {
773
865
  this.callAddingInProgress = undefined;
@@ -779,11 +871,13 @@ class OpenSIPSJS extends UA_1.default {
779
871
  this._stopCallTimer(session.id);
780
872
  this._removeCallStatus(session.id);
781
873
  this._removeCallMetrics(session.id);
782
- if (!Object.keys(this.state.extendedCalls).length) {
783
- this.isMuted = false;
874
+ if (!Object.keys(this.extendedCalls).length) {
875
+ this.setIsMuted(false);
784
876
  }
785
877
  });
786
878
  session.on('confirmed', (event) => {
879
+ var _a, _b;
880
+ this.logger.log('Session confirmed for', (_b = (_a = session._remote_identity) === null || _a === void 0 ? void 0 : _a._uri) === null || _b === void 0 ? void 0 : _b._user);
787
881
  this._triggerListener({ listenerType: call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_CONFIRMED, session, event });
788
882
  this.updateCall(session);
789
883
  if (session.id === this.callAddingInProgress) {
@@ -796,37 +890,145 @@ class OpenSIPSJS extends UA_1.default {
796
890
  this.setCurrentActiveRoomId(roomId);
797
891
  }
798
892
  }
893
+ newMSRPSessionCallback(event) {
894
+ const session = event.session;
895
+ /*if (this.isDND) {
896
+ session.terminate({ status_code: 486, reason_phrase: 'Do Not Disturb' })
897
+ return
898
+ }*/
899
+ // stop timers on ended and failed
900
+ session.on('ended', (event) => {
901
+ this._triggerMSRPListener({ listenerType: call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_ENDED, session, event });
902
+ const s = this.getActiveMessages[session.id];
903
+ this._activeMessageListRemove(s);
904
+ //this._stopCallTimer(session.id)
905
+ //this._removeCallStatus(session.id)
906
+ //this._removeCallMetrics(session.id)
907
+ /*if (!Object.keys(activeMessages).length) {
908
+ this.isMuted = false
909
+ }*/
910
+ });
911
+ /*session.on('active', (event: Event) => {
912
+ console.log('event newMSRPSessionCallback active', session)
913
+ //this._triggerMSRPListener({ listenerType: CALL_EVENT_LISTENER_TYPE.CALL_PROGRESS, session, event })
914
+ })*/
915
+ session.on('failed', (event) => {
916
+ this._triggerMSRPListener({ listenerType: call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_FAILED, session, event });
917
+ /*if (session.id === this.callAddingInProgress) {
918
+ this.callAddingInProgress = undefined
919
+ }*/
920
+ // console.log(session, '0000000000000000000000000')
921
+ const s = this.getActiveMessages[session.id];
922
+ this._activeMessageListRemove(s);
923
+ //this._stopCallTimer(session.id)
924
+ //this._removeCallStatus(session.id)
925
+ //this._removeCallMetrics(session.id)
926
+ /*if (!Object.keys(activeMessages).length) {
927
+ this.isMuted = false
928
+ }*/
929
+ });
930
+ session.on('confirmed', (event) => {
931
+ this._triggerMSRPListener({ listenerType: call_event_listener_type_1.CALL_EVENT_LISTENER_TYPE.CALL_CONFIRMED, session, event });
932
+ this.updateMSRPSession(session);
933
+ /*if (session.id === this.callAddingInProgress) {
934
+ this.callAddingInProgress = undefined
935
+ }*/
936
+ });
937
+ session.on('newMessage', (msg) => {
938
+ this._addMSRPMessage(msg, session);
939
+ });
940
+ this.addMessageSession(session);
941
+ /*if (session.direction === 'outgoing') {
942
+ const roomId = this.getActiveMessages[session.id].roomId
943
+ this.setCurrentActiveRoomId(roomId)
944
+ }*/
945
+ }
799
946
  setInitialized(value) {
800
947
  this.initialized = value;
801
948
  this.emit('ready', value);
802
949
  }
803
- start() {
950
+ begin() {
951
+ if (this.isConnected()) {
952
+ console.error('Connection is already established');
953
+ return;
954
+ }
804
955
  this.on(this.registeredEventName, () => {
956
+ this.logger.log('Successfully registered to', this.options.socketInterfaces[0]);
805
957
  this.setInitialized(true);
806
958
  });
807
959
  this.on(this.unregisteredEventName, () => {
960
+ this.logger.log('Unregistered from', this.options.socketInterfaces[0]);
808
961
  this.setInitialized(false);
809
962
  });
810
963
  this.on(this.newRTCSessionEventName, this.newRTCSessionCallback.bind(this));
811
- super.start();
964
+ this.on(this.connectedEventName, () => {
965
+ this.logger.log('Connected to', this.options.socketInterfaces[0]);
966
+ this.isReconnecting = false;
967
+ });
968
+ this.on(this.disconnectedEventName, () => {
969
+ if (this.isReconnecting) {
970
+ return;
971
+ }
972
+ this.logger.log('Disconnected from', this.options.socketInterfaces[0]);
973
+ this.logger.log('Reconnecting to', this.options.socketInterfaces[0]);
974
+ this.isReconnecting = true;
975
+ this.stop();
976
+ this.setInitialized(false);
977
+ setTimeout(this.start.bind(this), 5000);
978
+ });
979
+ this.on(this.newMSRPSessionEventName, this.newMSRPSessionCallback.bind(this));
980
+ this.logger.log('Connecting to', this.options.socketInterfaces[0]);
981
+ this.start();
812
982
  this.setMediaDevices(true);
813
983
  return this;
814
984
  }
815
985
  setMuteWhenJoin(value) {
816
- this.muteWhenJoin = value;
986
+ this.muteWhenJoinEnabled = value;
987
+ this.emit('changeMuteWhenJoin', value);
988
+ }
989
+ setMicrophoneInputLevel(value) {
990
+ this.microphoneInputLevelValue = value;
991
+ this.roomReconfigure(this.currentActiveRoomId);
992
+ }
993
+ setSpeakerVolume(value) {
994
+ this.speakerVolumeValue = value;
995
+ Object.values(this.extendedCalls).forEach((call) => {
996
+ if (call.audioTag) {
997
+ call.audioTag.volume = value;
998
+ }
999
+ });
1000
+ }
1001
+ setAutoAnswer(value) {
1002
+ this.isAutoAnswer = value;
1003
+ }
1004
+ setSelectedInputDevice(deviceId) {
1005
+ localStorage.setItem(STORAGE_KEYS.SELECTED_INPUT_DEVICE, deviceId);
1006
+ this.selectedMediaDevices.input = deviceId;
1007
+ this.emit('changeActiveInputMediaDevice', deviceId);
1008
+ }
1009
+ setSelectedOutputDevice(deviceId) {
1010
+ localStorage.setItem(STORAGE_KEYS.SELECTED_OUTPUT_DEVICE, deviceId);
1011
+ this.selectedMediaDevices.output = deviceId;
1012
+ this.emit('changeActiveOutputMediaDevice', deviceId);
1013
+ }
1014
+ setIsMSRPInitializing(value) {
1015
+ this.isMSRPInitializingValue = value;
1016
+ this.emit('isMSRPInitializingChanged', value);
817
1017
  }
818
1018
  _setCallMetrics(value) {
819
1019
  const metrics = Object.assign({}, value);
820
1020
  delete metrics['callId'];
821
- this.state.callMetrics = Object.assign(Object.assign({}, this.state.callMetrics), { [value.callId]: metrics });
1021
+ this.callMetrics = Object.assign(Object.assign({}, this.callMetrics), { [value.callId]: metrics });
1022
+ this.emit('changeCallMetrics', this.callMetrics);
822
1023
  }
823
1024
  _removeCallMetrics(callId) {
824
- const callMetricsCopy = Object.assign({}, this.state.callMetrics);
1025
+ const callMetricsCopy = Object.assign({}, this.callMetrics);
825
1026
  delete callMetricsCopy[callId];
826
- this.state.callMetrics = Object.assign({}, callMetricsCopy);
1027
+ this.callMetrics = Object.assign({}, callMetricsCopy);
1028
+ this.emit('changeCallMetrics', this.callMetrics);
827
1029
  }
828
1030
  _getCallQuality(call) {
829
- const metrics = new metrics_1.default(this.state.metricConfig);
1031
+ const metrics = new metrics_1.default(this.metricConfig);
830
1032
  const probe = metrics.createProbe(call.connection, {
831
1033
  cid: call._id
832
1034
  });
@@ -864,7 +1066,7 @@ class OpenSIPSJS extends UA_1.default {
864
1066
  }
865
1067
  _triggerAddStream(event, call) {
866
1068
  return __awaiter(this, void 0, void 0, function* () {
867
- this.isMuted = this.muteWhenJoin;
1069
+ this.setIsMuted(this.muteWhenJoin);
868
1070
  const stream = yield navigator.mediaDevices.getUserMedia(this.getUserMediaConstraints);
869
1071
  const processedStream = (0, audio_helper_1.processAudioVolume)(stream, this.microphoneInputLevel);
870
1072
  const muteMicro = this.isMuted || this.muteWhenJoin;
@@ -881,6 +1083,7 @@ class OpenSIPSJS extends UA_1.default {
881
1083
  if (target.length === 0) {
882
1084
  return console.error('Target must be a valid string');
883
1085
  }
1086
+ this.logger.log(`Calling sip:${target}@${this.sipDomain}...`);
884
1087
  const call = this.call(`sip:${target}@${this.sipDomain}`, this.sipOptions);
885
1088
  this.callAddingInProgress = call.id;
886
1089
  if (addToCurrentRoom && this.currentActiveRoomId !== undefined) {
@@ -893,10 +1096,37 @@ class OpenSIPSJS extends UA_1.default {
893
1096
  this._triggerAddStream(event, call);
894
1097
  });
895
1098
  }
1099
+ initMSRP(target, body, options) {
1100
+ this.checkInitialized();
1101
+ if (target.length === 0) {
1102
+ return console.error('Target must be a valid string');
1103
+ }
1104
+ const session = this.startMSRP(target, options);
1105
+ session.on('active', () => {
1106
+ this.addMessageSession(session);
1107
+ session.sendMSRP(body);
1108
+ this.setIsMSRPInitializing(false);
1109
+ });
1110
+ this.setIsMSRPInitializing(true);
1111
+ // if (this.currentActiveRoomId !== undefined) {
1112
+ // this.callChangeRoom({
1113
+ // callId: call.id,
1114
+ // roomId: this.currentActiveRoomId
1115
+ // })
1116
+ // }
1117
+ //this.updateMSRPSession(session)
1118
+ }
1119
+ sendMSRP(msrpSessionId, body) {
1120
+ const msrpSession = this.extendedMessages[msrpSessionId];
1121
+ if (!msrpSession) {
1122
+ throw new Error(`MSRP session with id ${msrpSessionId} doesn't exist!`);
1123
+ }
1124
+ msrpSession.sendMSRP(body);
1125
+ }
896
1126
  callChangeRoom({ callId, roomId }) {
897
1127
  return __awaiter(this, void 0, void 0, function* () {
898
- const oldRoomId = this.state.extendedCalls[callId].roomId;
899
- this.state.extendedCalls[callId].roomId = roomId;
1128
+ const oldRoomId = this.extendedCalls[callId].roomId;
1129
+ this.extendedCalls[callId].roomId = roomId;
900
1130
  yield this.setCurrentActiveRoomId(roomId);
901
1131
  return Promise.all([
902
1132
  this.roomReconfigure(oldRoomId),