Added reconnect mechanism

This commit is contained in:
Adhiraj
2020-08-25 00:26:47 +05:30
parent e2372bf60b
commit 68b64b9707
5 changed files with 38 additions and 21 deletions

View File

@@ -18,14 +18,18 @@ export class WAConnection extends Base {
* @param jid the ID of the person/group who you are updating
* @param type your presence
*/
async updatePresence(jid: string | null, type: Presence) {
const json = [
'action',
{ epoch: this.msgCount.toString(), type: 'set' },
[['presence', { type: type, to: jid }, null]],
]
return this.query({json, binaryTags: [WAMetric.group, WAFlag.acknowledge]}) as Promise<{ status: number }>
}
updatePresence = (jid: string | null, type: Presence) =>
this.query(
{
json: [
'action',
{ epoch: this.msgCount.toString(), type: 'set' },
[['presence', { type: type, to: jid }, null]],
],
binaryTags: [WAMetric.group, WAFlag.acknowledge],
expect200: true
}
) as Promise<{status: number}>
/** Request an update on the presence of a user */
requestPresenceUpdate = async (jid: string) => this.query({json: ['action', 'presence', 'subscribe', jid]})
/** Query the status of the person (see groupMetadata() for groups) */