This commit is contained in:
Adhiraj
2020-03-16 16:30:53 +05:30
parent 3e1142a464
commit 9a963f4dcc
2 changed files with 4 additions and 1 deletions

View File

@@ -166,6 +166,8 @@ module.exports = function (WhatsAppWeb) {
} }
}, 25 * 1000) }, 25 * 1000)
} }
// disconnect from the phone. Your auth credentials become invalid after sending a disconnect request.
// use close() if you just want to close the connection
WhatsAppWeb.prototype.disconnect = function () { WhatsAppWeb.prototype.disconnect = function () {
if (this.status === Status.connected) { if (this.status === Status.connected) {
this.conn.send('goodbye,["admin","Conn","disconnect"]', null, () => { this.conn.send('goodbye,["admin","Conn","disconnect"]', null, () => {
@@ -177,6 +179,7 @@ module.exports = function (WhatsAppWeb) {
this.close() this.close()
} }
} }
// close the connection
WhatsAppWeb.prototype.close = function () { WhatsAppWeb.prototype.close = function () {
this.conn.close() this.conn.close()
this.conn = null this.conn = null

View File

@@ -39,7 +39,7 @@ const readline = require('readline').createInterface({
}) })
readline.question("type exit to disconnect\n", (txt) => { readline.question("type exit to disconnect\n", (txt) => {
if (txt === "exit") { if (txt === "exit") {
client.disconnect() client.close()
process.exit(0) process.exit(0)
} }
}) })