mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Update 3.Connect.ts
This commit is contained in:
@@ -16,7 +16,7 @@ export class WAConnection extends Base {
|
|||||||
this.emit ('connecting')
|
this.emit ('connecting')
|
||||||
|
|
||||||
const { ws, cancel } = Utils.openWebSocketConnection (5000, typeof options?.retryOnNetworkErrors === 'undefined' ? true : options?.retryOnNetworkErrors)
|
const { ws, cancel } = Utils.openWebSocketConnection (5000, typeof options?.retryOnNetworkErrors === 'undefined' ? true : options?.retryOnNetworkErrors)
|
||||||
const promise: Promise<void> = Utils.promiseTimeout(options?.timeoutMs, (resolve, reject) => {
|
const promise = Utils.promiseTimeout(options?.timeoutMs, (resolve, reject) => {
|
||||||
ws
|
ws
|
||||||
.then (conn => this.conn = conn)
|
.then (conn => this.conn = conn)
|
||||||
.then (() => this.conn.on('message', data => this.onMessageRecieved(data as any)))
|
.then (() => this.conn.on('message', data => this.onMessageRecieved(data as any)))
|
||||||
@@ -29,11 +29,12 @@ export class WAConnection extends Base {
|
|||||||
this.conn.on ('close', () => this.unexpectedDisconnect ('close'))
|
this.conn.on ('close', () => this.unexpectedDisconnect ('close'))
|
||||||
})
|
})
|
||||||
.then (resolve)
|
.then (resolve)
|
||||||
.catch (err => {
|
.catch (reject)
|
||||||
cancel ()
|
|
||||||
reject (err)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
.catch (err => {
|
||||||
|
cancel ()
|
||||||
|
throw err
|
||||||
|
}) as Promise<void>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const tasks = [promise]
|
const tasks = [promise]
|
||||||
|
|||||||
Reference in New Issue
Block a user