mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
chore: update legacy connection close msgs
This commit is contained in:
@@ -34,11 +34,11 @@ const makeAuthSocket = (config: LegacySocketConfig) => {
|
|||||||
})
|
})
|
||||||
// add close listener
|
// add close listener
|
||||||
ws.on('ws-close', (error: Boom | Error) => {
|
ws.on('ws-close', (error: Boom | Error) => {
|
||||||
logger.info({ error }, 'Closed connection to WhatsApp')
|
logger.info({ error }, 'closed connection to WhatsApp')
|
||||||
initTimeout && clearTimeout(initTimeout)
|
initTimeout && clearTimeout(initTimeout)
|
||||||
// if no reconnects occur
|
// if no reconnects occur
|
||||||
// send close event
|
// send close event
|
||||||
updateState({
|
updateState({
|
||||||
connection: 'close',
|
connection: 'close',
|
||||||
qr: undefined,
|
qr: undefined,
|
||||||
lastDisconnect: {
|
lastDisconnect: {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ export const makeSocket = ({
|
|||||||
return tag
|
return tag
|
||||||
}
|
}
|
||||||
const end = (error: Error | undefined) => {
|
const end = (error: Error | undefined) => {
|
||||||
logger.debug({ error }, 'connection closed')
|
logger.info({ error }, 'connection closed')
|
||||||
|
|
||||||
ws.removeAllListeners('close')
|
ws.removeAllListeners('close')
|
||||||
ws.removeAllListeners('error')
|
ws.removeAllListeners('error')
|
||||||
@@ -213,7 +213,7 @@ export const makeSocket = ({
|
|||||||
*/
|
*/
|
||||||
const waitForMessage = (tag: string, requiresPhoneConnection: boolean, timeoutMs?: number) => {
|
const waitForMessage = (tag: string, requiresPhoneConnection: boolean, timeoutMs?: number) => {
|
||||||
if(ws.readyState !== ws.OPEN) {
|
if(ws.readyState !== ws.OPEN) {
|
||||||
throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })
|
throw new Boom('Connection not open', { statusCode: DisconnectReason.connectionClosed })
|
||||||
}
|
}
|
||||||
|
|
||||||
let cancelToken = () => { }
|
let cancelToken = () => { }
|
||||||
@@ -228,7 +228,7 @@ export const makeSocket = ({
|
|||||||
(resolve, reject) => {
|
(resolve, reject) => {
|
||||||
onRecv = resolve
|
onRecv = resolve
|
||||||
onErr = err => {
|
onErr = err => {
|
||||||
reject(err || new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed }))
|
reject(err || new Boom('Intentional Close', { statusCode: DisconnectReason.connectionClosed }))
|
||||||
}
|
}
|
||||||
cancelToken = () => onErr(new Boom('Cancelled', { statusCode: 500 }))
|
cancelToken = () => onErr(new Boom('Cancelled', { statusCode: 500 }))
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ export const makeSocket = ({
|
|||||||
const waitForSocketOpen = async() => {
|
const waitForSocketOpen = async() => {
|
||||||
if(ws.readyState === ws.OPEN) return
|
if(ws.readyState === ws.OPEN) return
|
||||||
if(ws.readyState === ws.CLOSED || ws.readyState === ws.CLOSING) {
|
if(ws.readyState === ws.CLOSED || ws.readyState === ws.CLOSING) {
|
||||||
throw new Boom('Connection Closed', { statusCode: DisconnectReason.connectionClosed })
|
throw new Boom('Connection Already Closed', { statusCode: DisconnectReason.connectionClosed })
|
||||||
}
|
}
|
||||||
let onOpen: () => void
|
let onOpen: () => void
|
||||||
let onClose: (err: Error) => void
|
let onClose: (err: Error) => void
|
||||||
|
|||||||
Reference in New Issue
Block a user