From 2688ac19dd0b108a3f6c8bcd127241b3afecbaef Mon Sep 17 00:00:00 2001 From: Balte de Wit Date: Fri, 25 Jan 2019 14:28:08 +0100 Subject: [PATCH] fix: reconnect logic on close event rather than end --- src/hyperdeck.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hyperdeck.ts b/src/hyperdeck.ts index 3fcfd0b..165205e 100644 --- a/src/hyperdeck.ts +++ b/src/hyperdeck.ts @@ -69,7 +69,8 @@ export class Hyperdeck extends EventEmitter { this.socket = new Socket() this.socket.setEncoding('utf8') this.socket.on('error', (e) => this.emit('error', e)) - this.socket.on('end', () => { + this.socket.on('close', () => { + if (this._connected) this.emit('disconnected') this._connected = false if (this._pingInterval) { @@ -77,8 +78,6 @@ export class Hyperdeck extends EventEmitter { this._pingInterval = null } - this.emit('disconnected') - this._triggerRetryConnection() }) this.socket.on('data', (d) => this._handleData(d.toString()))