@wazo/sdk 1.0.0-alpha.7 → 1.0.0-alpha.8
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/dist/wazo-sdk.js +2 -2
- package/esm/state-machine/softphone-state-machine.js +1 -2
- package/esm/types/state-machine/softphone-state-machine.d.ts +0 -1
- package/esm/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/esm/types/voice/call.d.ts.map +1 -1
- package/esm/types/voice/softphone.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +2 -1
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/voice/call.js +2 -0
- package/esm/voice/softphone.js +23 -6
- package/esm/web-rtc-client.js +8 -4
- package/lib/state-machine/softphone-state-machine.js +1 -2
- package/lib/types/state-machine/softphone-state-machine.d.ts +0 -1
- package/lib/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/lib/types/voice/call.d.ts.map +1 -1
- package/lib/types/voice/softphone.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +2 -1
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/voice/call.js +2 -0
- package/lib/voice/softphone.js +24 -6
- package/lib/web-rtc-client.js +7 -4
- package/package.json +1 -1
- package/src/state-machine/softphone-state-machine.ts +1 -2
- package/src/voice/call.ts +2 -0
- package/src/voice/softphone.ts +30 -7
- package/src/web-rtc-client.ts +10 -4
package/src/voice/softphone.ts
CHANGED
|
@@ -93,6 +93,8 @@ export class Softphone extends EventEmitter {
|
|
|
93
93
|
const server = Wazo.Auth.getHost();
|
|
94
94
|
const session = Wazo.Auth.getSession();
|
|
95
95
|
|
|
96
|
+
logger.info('softphone - connect', { server, session: !!session });
|
|
97
|
+
|
|
96
98
|
if (!server || !session) {
|
|
97
99
|
throw new Error('Please connect to the server using `Wazo.Auth.logIn` or `Wazo.Auth.authenticate` before using Room.connect().');
|
|
98
100
|
}
|
|
@@ -116,6 +118,7 @@ export class Softphone extends EventEmitter {
|
|
|
116
118
|
async disconnect() {
|
|
117
119
|
assertCan(this.softphoneActor, Actions.UNREGISTER);
|
|
118
120
|
if (!this.client) {
|
|
121
|
+
logger.info('softphone - disconnect, not client to disconnect, bailing');
|
|
119
122
|
return null;
|
|
120
123
|
}
|
|
121
124
|
|
|
@@ -137,7 +140,9 @@ export class Softphone extends EventEmitter {
|
|
|
137
140
|
): Promise<void> {
|
|
138
141
|
assertCan(this.softphoneActor, Actions.REGISTER);
|
|
139
142
|
|
|
140
|
-
|
|
143
|
+
logger.info('softphone - connect with credentials', { server, username: sipLine.username, displayName, options: rawOptions });
|
|
144
|
+
|
|
145
|
+
this._sendAction(Actions.REGISTER);
|
|
141
146
|
|
|
142
147
|
const [host, port = 443] = server.split(':');
|
|
143
148
|
let options = { ...rawOptions };
|
|
@@ -291,7 +296,7 @@ export class Softphone extends EventEmitter {
|
|
|
291
296
|
}
|
|
292
297
|
|
|
293
298
|
startHeartbeat() {
|
|
294
|
-
logger.info('softphone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client
|
|
299
|
+
logger.info('softphone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client?.hasHeartbeat() });
|
|
295
300
|
if (!this.client || this.client.hasHeartbeat()) {
|
|
296
301
|
return;
|
|
297
302
|
}
|
|
@@ -456,22 +461,32 @@ export class Softphone extends EventEmitter {
|
|
|
456
461
|
|
|
457
462
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
458
463
|
logger.info('softphone - unregistered');
|
|
459
|
-
this.
|
|
464
|
+
if (!can(this.softphoneActor, Actions.UNREGISTER)) {
|
|
465
|
+
logger.warn('softphone - cannot unregister', { state: this.state });
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
this._sendAction(Actions.UNREGISTER);
|
|
460
470
|
|
|
461
|
-
this.
|
|
471
|
+
this.emit(EVENT_UNREGISTERED);
|
|
462
472
|
});
|
|
463
473
|
|
|
464
474
|
this.client.on(this.client.ON_DISCONNECTED, () => {
|
|
465
475
|
logger.info('softphone - disconnected');
|
|
466
|
-
this.
|
|
476
|
+
if (!can(this.softphoneActor, Actions.TRANSPORT_CLOSED)) {
|
|
477
|
+
logger.warn('softphone - cannot disconnected', { state: this.state });
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
467
480
|
|
|
468
481
|
this._sendAction(Actions.TRANSPORT_CLOSED);
|
|
482
|
+
|
|
483
|
+
this.emit(EVENT_DISCONNECTED);
|
|
469
484
|
});
|
|
470
485
|
|
|
471
486
|
this.client.on(this.client.REGISTERED, () => {
|
|
472
487
|
logger.info('softphone - registered', { state: getState(this.softphoneActor) });
|
|
473
488
|
if (!can(this.softphoneActor, Actions.REGISTER_DONE)) {
|
|
474
|
-
logger.warn('softphone - registered but not in REGISTERING state', { state:
|
|
489
|
+
logger.warn('softphone - registered but not in REGISTERING state', { state: this.state });
|
|
475
490
|
return;
|
|
476
491
|
}
|
|
477
492
|
|
|
@@ -492,10 +507,16 @@ export class Softphone extends EventEmitter {
|
|
|
492
507
|
});
|
|
493
508
|
|
|
494
509
|
this.client.on(this.client.CONNECTED, () => {
|
|
495
|
-
logger.info('softphone - connected');
|
|
510
|
+
logger.info('softphone - connected', { state: this.state });
|
|
496
511
|
this.stopHeartbeat();
|
|
497
512
|
});
|
|
498
513
|
|
|
514
|
+
this.client.on(this.client.REGISTERING, () => {
|
|
515
|
+
logger.info('softphone - registering', { state: this.state });
|
|
516
|
+
|
|
517
|
+
this._sendAction(Actions.REGISTER);
|
|
518
|
+
});
|
|
519
|
+
|
|
499
520
|
this.client.on(this.client.DISCONNECTED, () => {
|
|
500
521
|
logger.info('softphone - disconnected');
|
|
501
522
|
this.emit(EVENT_DISCONNECTED);
|
|
@@ -529,7 +550,9 @@ export class Softphone extends EventEmitter {
|
|
|
529
550
|
}
|
|
530
551
|
|
|
531
552
|
private _sendAction(action: ActionTypes) {
|
|
553
|
+
const was = this.state;
|
|
532
554
|
this.softphoneActor.send({ type: action });
|
|
555
|
+
logger.trace('softphone - send action', { action, was, state: this.state });
|
|
533
556
|
}
|
|
534
557
|
|
|
535
558
|
private _getCall(sipCall: SipCall): Call | undefined {
|
package/src/web-rtc-client.ts
CHANGED
|
@@ -39,6 +39,7 @@ const logger = IssueReporter ? IssueReporter.loggerFor('webrtc-client') : consol
|
|
|
39
39
|
const statsLogger = IssueReporter ? IssueReporter.loggerFor('webrtc-stats') : console;
|
|
40
40
|
// events
|
|
41
41
|
const REGISTERED = 'registered';
|
|
42
|
+
const REGISTERING = 'registering';
|
|
42
43
|
const UNREGISTERED = 'unregistered';
|
|
43
44
|
const REGISTRATION_FAILED = 'registrationFailed';
|
|
44
45
|
const INVITE = 'invite';
|
|
@@ -57,7 +58,7 @@ const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
|
|
|
57
58
|
const ON_NETWORK_STATS = 'onNetworkStats';
|
|
58
59
|
const ON_DISCONNECTED = 'onDisconnected';
|
|
59
60
|
|
|
60
|
-
export const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
61
|
+
export const events = [REGISTERED, REGISTERING, UNREGISTERED, REGISTRATION_FAILED, INVITE];
|
|
61
62
|
export const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
|
|
62
63
|
export class CanceledCallError extends Error {}
|
|
63
64
|
|
|
@@ -119,6 +120,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
119
120
|
|
|
120
121
|
REGISTERED: string;
|
|
121
122
|
|
|
123
|
+
REGISTERING: string;
|
|
124
|
+
|
|
122
125
|
UNREGISTERED: string;
|
|
123
126
|
|
|
124
127
|
REGISTRATION_FAILED: string;
|
|
@@ -196,6 +199,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
196
199
|
this.heartbeat.setOnHeartbeatTimeout(this._onHeartbeatTimeout.bind(this));
|
|
197
200
|
// sugar
|
|
198
201
|
this.REGISTERED = REGISTERED;
|
|
202
|
+
this.REGISTERING = REGISTERING;
|
|
199
203
|
this.UNREGISTERED = UNREGISTERED;
|
|
200
204
|
this.REGISTRATION_FAILED = REGISTRATION_FAILED;
|
|
201
205
|
this.INVITE = INVITE;
|
|
@@ -343,6 +347,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
343
347
|
|
|
344
348
|
logger.info('sdk webrtc registering...', logInfo);
|
|
345
349
|
|
|
350
|
+
this.eventEmitter.emit(REGISTERING);
|
|
351
|
+
|
|
346
352
|
if (!this.userAgent) {
|
|
347
353
|
logger.info('sdk webrtc recreating User Agent');
|
|
348
354
|
this.userAgent = this.createUserAgent(this.uaConfigOverrides);
|
|
@@ -1547,8 +1553,8 @@ export default class WebRTCClient extends Emitter {
|
|
|
1547
1553
|
return audio;
|
|
1548
1554
|
}
|
|
1549
1555
|
|
|
1550
|
-
_onTransportError(): void {
|
|
1551
|
-
logger.
|
|
1556
|
+
_onTransportError(reason?: string): void {
|
|
1557
|
+
logger.warn('on transport error', { reason });
|
|
1552
1558
|
this.eventEmitter.emit(TRANSPORT_ERROR);
|
|
1553
1559
|
this.attemptReconnection();
|
|
1554
1560
|
}
|
|
@@ -1610,7 +1616,7 @@ export default class WebRTCClient extends Emitter {
|
|
|
1610
1616
|
}
|
|
1611
1617
|
|
|
1612
1618
|
// We can invoke disconnect() with an error that can be catcher by `onDisconnect`, so we have to trigger it here.
|
|
1613
|
-
this._onTransportError();
|
|
1619
|
+
this._onTransportError('heartbeat timeout');
|
|
1614
1620
|
}
|
|
1615
1621
|
}
|
|
1616
1622
|
|