webitel-sdk 0.1.145 → 0.1.146

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.
@@ -25556,7 +25556,7 @@ async function getMediaStream(constraints) {
25556
25556
 
25557
25557
  const getVersion = () => {
25558
25558
  // @ts-ignore
25559
- return '"0.1.145"';
25559
+ return '"0.1.146"';
25560
25560
  };
25561
25561
  var version = getVersion();
25562
25562
 
@@ -27188,29 +27188,34 @@ class Client extends EventEmitter {
27188
27188
  }
27189
27189
  async registerCallClient(phone) {
27190
27190
  this.phone = phone;
27191
- this.phone.on('peerStreams', (session, streams) => {
27191
+ this.subscribePhone(phone);
27192
+ try {
27193
+ const conf = await this.deviceConfig(this.phone.type);
27194
+ await this.phone.register(conf);
27195
+ }
27196
+ catch (e) {
27197
+ // FIXME add handle error
27198
+ this.log.error(e);
27199
+ }
27200
+ }
27201
+ subscribePhone(phone) {
27202
+ phone.on('peerStreams', (session, streams) => {
27192
27203
  const call = this.callBySession(session);
27193
27204
  if (call && !call.peerStreams.length) {
27194
27205
  call.setPeerStreams(streams);
27195
27206
  this.eventHandler.emit(WEBSOCKET_EVENT_CALL, CallActions.PeerStream, call);
27196
27207
  }
27197
27208
  });
27198
- this.phone.on('localStreams', (session, streams) => {
27209
+ phone.on('localStreams', (session, streams) => {
27199
27210
  const call = this.callBySession(session);
27200
27211
  if (call && !call.localStreams.length) {
27201
27212
  call.setLocalStreams(streams);
27202
27213
  this.eventHandler.emit(WEBSOCKET_EVENT_CALL, CallActions.LocalStream, call);
27203
27214
  }
27204
27215
  });
27205
- this.phone.on('newSession', this.onNewCallSession.bind(this));
27206
- try {
27207
- const conf = await this.deviceConfig(this.phone.type);
27208
- await this.phone.register(conf);
27209
- }
27210
- catch (e) {
27211
- // FIXME add handle error
27212
- this.log.error(e);
27213
- }
27216
+ phone.on('newSession', this.onNewCallSession.bind(this));
27217
+ phone.on('registered', () => this.emit('phone_registered', true));
27218
+ phone.on('unregistered', () => this.emit('phone_registered', false));
27214
27219
  }
27215
27220
  async deviceConfig(name) {
27216
27221
  return this.request(WEBSOCKET_DEFAULT_DEVICE_CONFIG, { name });