From bbf40cba72b76eaf64080e7d89300f2a2b14a85a Mon Sep 17 00:00:00 2001 From: rodrigorodriguez Date: Tue, 4 Oct 2022 15:51:09 -0300 Subject: [PATCH] new(all): Custom Domain support per bot. --- .../services/WhatsappDirectLine.ts | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index e5123f39..c59bd29c 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -195,26 +195,27 @@ export class WhatsappDirectLine extends GBService { client.on('authenticated', () => { this.browserWSEndpoint = client.pupBrowser.wsEndpoint(); + client.pupBrowser.on('disconnected', (async () => { + GBLog.info(`Browser crashed. Restarting ${this.min.botId} WhatsApp native provider.`); + await (createClient.bind(this))(null); + }).bind(this)); + client.pupPage.on('error', (async () => { + GBLog.info(`Page crashed. Restarting ${this.min.botId} WhatsApp native provider.`); + if (!client.pupPage.isClosed()){ + client.pupPage.close(); + } await (createClient.bind(this))(null); + }).bind(this)); + GBLog.info(`WhatsApp QR Code authenticated for ${this.botId}.`); }); - client.pupBrowser.on('disconnected', (async () => { - GBLog.info(`555555`); - await (createClient.bind(this))(null); - }).bind(this)); - client.pupPage.on('error', (async () => { - GBLog.info(`22222s`); - if (!client.pupPage.isClosed()){ - client.pupPage.close(); - } await (createClient.bind(this))(null); - }).bind(this)); - + }; await (createClient.bind(this))(this.browserWSEndpoint); client.initialize(); - + setUrl = false; } break;