Terminate connection on false pong

This commit is contained in:
Adhiraj Singh
2020-12-18 17:33:58 +05:30
parent b6a8d02038
commit 597f073948

View File

@@ -211,6 +211,11 @@ export class WAConnection extends Base {
if (anyTriggered) return
if (this.state === 'open' && json[0] === 'Pong') {
if (!json[1]) {
this.closeInternal(DisconnectReason.close)
this.logger.info('Connection terminated by phone, closing...')
return
}
if (this.phoneConnected !== json[1]) {
this.phoneConnected = json[1]
this.emit ('connection-phone-change', { connected: this.phoneConnected })