Skip to content

Commit

Permalink
fix: reconnect logic on close event rather than end
Browse files Browse the repository at this point in the history
  • Loading branch information
Balte de Wit committed Jan 25, 2019
1 parent 7175946 commit 2688ac1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/hyperdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,15 @@ 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) {
clearInterval(this._pingInterval)
this._pingInterval = null
}

this.emit('disconnected')

this._triggerRetryConnection()
})
this.socket.on('data', (d) => this._handleData(d.toString()))
Expand Down

0 comments on commit 2688ac1

Please sign in to comment.