Takeover conflict implementation

This commit is contained in:
Adhiraj
2020-07-10 12:44:31 +05:30
parent 2dad372e75
commit 2a7d179822
4 changed files with 29 additions and 6 deletions

View File

@@ -13,6 +13,14 @@ import {
import { generateMessageTag } from '../WAConnection/Utils'
export default class WhatsAppWebBase extends WAConnection {
/** Set the callback for when the connection is taken over somewhere else */
setOnTakenOver(callback: (kind: 'replaced' | string | null) => void) {
this.registerCallback (['Cmd', 'type:disconnect'], json => {
this.log ('connection taken over elsewhere')
this.close ()
callback (json[1].kind)
})
}
/** Set the callback for unexpected disconnects */
setOnUnexpectedDisconnect(callback: (error: Error) => void) {
this.unexpectedDisconnect = (err) => {