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

@@ -104,6 +104,7 @@ client.connectSlim(null, 20*1000) // use loaded credentials & timeout in 20s
See the browser credentials type [here](/src/WAConnection/Constants.ts).
## Handling Events
Implement the following callbacks in your code:
- Called when you have a pending unread message or recieve a new message
@@ -136,6 +137,13 @@ Implement the following callbacks in your code:
``` ts
client.setOnUnexpectedDisconnect (err => console.log ("disconnected unexpectedly: " + err) )
```
- Called when you log into WhatsApp Web somewhere else
``` ts
client.setOnTakenOver (async () => {
// reconnect to gain connection back here
await client.connect ()
})
```
## Sending Messages
Send like, all types of messages with a single function:
@@ -183,16 +191,20 @@ To note:
}
```
## Sending Read Receipts
## Reading Messages
``` ts
const id = '1234-123@g.us'
const messageID = 'AHASHH123123AHGA' // id of the message you want to read
await client.sendReadReceipt(id, messageID) // mark as read
await client.markChatUnread(id) // to mark chat as unread
await client.sendReadReceipt(id, messageID) // mark as read
await client.sendReadReceipt (id) // mark all messages in chat as read
await client.sendReadReceipt(id, null, 'unread') // mark the chat as unread
```
`id` is in the same format as mentioned earlier. The message ID is the unique identifier of the message that you are marking as read. On a `WAMessage`, it can be accessed using ```messageID = message.key.id```.
- `id` is in the same format as mentioned earlier.
- The message ID is the unique identifier of the message that you are marking as read.
- On a `WAMessage`, the `messageID` can be accessed using ```messageID = message.key.id```.
## Update Presence
``` ts