You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -362,7 +384,11 @@ class Worker extends EventEmitter {
362
384
363
385
try{
364
386
this._config.updateToken(newToken);
365
-
this._signaling.updateToken(newToken);
387
+
if(this._useGraphQL){
388
+
this._gqlSignaling.updateToken(newToken);
389
+
}else{
390
+
this._signaling.updateToken(newToken);
391
+
}
366
392
this.emit('tokenUpdated');
367
393
}catch(err){
368
394
this.emit('error',err);
@@ -417,13 +443,53 @@ class Worker extends EventEmitter {
417
443
});
418
444
}
419
445
446
+
/**
447
+
* @private
448
+
*/
449
+
_subscribeToGQLEvents(){
450
+
this._log.info('[GQL] Subscribing to Signaling events .... ');
451
+
452
+
this._gqlSignaling.on('connected',()=>{
453
+
this._log.info('[GQL] Received Event: \'connected\' from Signaling layer. Pending initialization.',this.sid);
454
+
});
455
+
456
+
this._gqlSignaling.on('disconnected',reason=>{
457
+
this._log.info('[GQL] Received Event: \'disconnected\' from Signaling layer for Worker %s. %s',this.sid,reason);
458
+
this._unSubscribeFromTaskRouterEvents();
459
+
this.emit('disconnected',reason);
460
+
});
461
+
462
+
this._gqlSignaling.on('init',evt=>{
463
+
this._log.info('[GQL] Received Event: \'init\' from Signaling layer. Proceeding to initialize Worker %s.',evt.channel_id);
464
+
this.sid=evt.channel_id;
465
+
this.accountSid=evt.account_sid;
466
+
this.workspaceSid=evt.workspace_sid;
467
+
// Check if we need this: this._gqlSignaling.setLifetime(evt.token_lifetime);
468
+
this._initialize();
469
+
});
470
+
471
+
this._gqlSignaling.on('error',err=>{
472
+
this._log.info('[GQL] Received Event: \'error\' from Signaling layer for Worker %s.',this.sid);
473
+
this.emit('error',err);
474
+
});
475
+
476
+
this._gqlSignaling.on('tokenExpired',()=>{
477
+
this._log.info('[GQL] Received Event: \'tokenExpired\' for for Worker %s. Please update the token. Websocket will not reconnect automatically until token is updated.',this.sid);
478
+
this.emit('tokenExpired');
479
+
});
480
+
}
481
+
420
482
/**
421
483
* @private
422
484
*/
423
485
_subscribeToTaskRouterEvents(){
424
486
this._log.info('Subscribing to TaskRouter events ... ');
0 commit comments