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()))