From 9a963f4dcc4bad44f9e201e6ace179501a2d114e Mon Sep 17 00:00:00 2001 From: Adhiraj Date: Mon, 16 Mar 2020 16:30:53 +0530 Subject: [PATCH] . --- WhatsAppWeb.Session.js | 3 +++ test.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/WhatsAppWeb.Session.js b/WhatsAppWeb.Session.js index aa64bc6..ab73d54 100644 --- a/WhatsAppWeb.Session.js +++ b/WhatsAppWeb.Session.js @@ -166,6 +166,8 @@ module.exports = function (WhatsAppWeb) { } }, 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 () { if (this.status === Status.connected) { this.conn.send('goodbye,["admin","Conn","disconnect"]', null, () => { @@ -177,6 +179,7 @@ module.exports = function (WhatsAppWeb) { this.close() } } + // close the connection WhatsAppWeb.prototype.close = function () { this.conn.close() this.conn = null diff --git a/test.js b/test.js index 5b05dba..b8ab28f 100644 --- a/test.js +++ b/test.js @@ -39,7 +39,7 @@ const readline = require('readline').createInterface({ }) readline.question("type exit to disconnect\n", (txt) => { if (txt === "exit") { - client.disconnect() + client.close() process.exit(0) } }) \ No newline at end of file