chore: handle pings

This commit is contained in:
Ricardo Arturo Cabral Mejía 2023-01-30 00:12:42 -05:00
parent 64432e6433
commit cef12fd0be

View File

@ -81,6 +81,7 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
.on('message', this.onClientMessage.bind(this))
.on('close', this.onClientClose.bind(this))
.on('pong', this.onClientPong.bind(this))
.on('ping', this.onClientPing.bind(this))
this
.on(WebSocketAdapterEvent.Heartbeat, this.onHeartbeat.bind(this))
@ -258,6 +259,12 @@ export class WebSocketAdapter extends EventEmitter implements IWebSocketAdapter
this.alive = true
}
private onClientPing(data: any) {
debugHeartbeat('client %s ping', this.clientId)
this.client.pong(data)
this.alive = true
}
private onClientClose() {
this.alive = false
this.subscriptions.clear()