mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Takeover conflict implementation
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -25,7 +25,7 @@ export default class WAConnectionBase {
|
||||
/** The version of WhatsApp Web we're telling the servers we are */
|
||||
version: [number, number, number] = [2, 2027, 10]
|
||||
/** The Browser we're telling the WhatsApp Web servers we are */
|
||||
browserDescription: [string, string, string] = Browsers.baileys ('Baileys')
|
||||
browserDescription: [string, string, string] = Browsers.baileys ('Chrome')
|
||||
/** Metadata like WhatsApp id, name set on WhatsApp etc. */
|
||||
userMetaData: UserMetaData = { id: null, name: null, phone: null }
|
||||
/** Should reconnect automatically after an unexpected disconnect */
|
||||
|
||||
Reference in New Issue
Block a user