fix(events watching): stop if not connected

Fixes vatesfr/xo-web#1799
This commit is contained in:
Julien Fontanet 2016-12-07 23:18:05 +01:00 committed by GitHub
parent 27e0621ad8
commit c7e6e72ce8

View File

@ -609,7 +609,7 @@ export class Xapi extends EventEmitter {
}
_watchEvents () {
const loop = () => this._sessionCall('event.from', [
const loop = () => this.status === CONNECTED && this._sessionCall('event.from', [
['*'],
this._fromToken,
60 + 0.1 // Force float.
@ -682,7 +682,7 @@ export class Xapi extends EventEmitter {
const watchEvents = () => this._sessionCall('event.register', [ ['*'] ]).then(loop)
const loop = () => this._sessionCall('event.next', []).then(onSuccess, onFailure)
const loop = () => this.status === CONNECTED && this._sessionCall('event.next', []).then(onSuccess, onFailure)
const onSuccess = events => {
this._processEvents(events)