feat: get current connection state

Note: This only partly works, since the state may not be updated on WhatsApp's end. In the case of not being able to reach the phone, the state is only updated when the user performs an action, such as sending a message. This means that the state may be CONNECTED when we check, but the phone's really not connected.

ref #43
This commit is contained in:
Pedro Lopez
2020-02-11 22:26:33 -04:00
parent e385563883
commit 67784bc797

View File

@@ -352,6 +352,16 @@ class Client extends EventEmitter {
}, status);
}
/**
* Gets the current connection state for the client
* @returns {WAState}
*/
async getState() {
return await this.pupPage.evaluate(() => {
return window.Store.AppState.state;
});
}
}
module.exports = Client;