mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: socket options
This commit is contained in:
@@ -12,7 +12,10 @@ export class MobileSocket extends Socket {
|
||||
}
|
||||
|
||||
override connect() {
|
||||
return super.connect(MOBILE_PORT, MOBILE_ENDPOINT, () => {
|
||||
return super.connect({
|
||||
host: MOBILE_ENDPOINT,
|
||||
port: MOBILE_PORT,
|
||||
}, () => {
|
||||
this.emit('open')
|
||||
})
|
||||
}
|
||||
@@ -38,6 +41,6 @@ export class MobileSocket extends Socket {
|
||||
}
|
||||
|
||||
send(data: unknown, cb?: ((err?: Error | undefined) => void) | undefined) {
|
||||
return super.write(data as Uint8Array | string, cb as ((err?: Error | undefined) => void))
|
||||
return super.write(data as Uint8Array | string, undefined, cb as ((err?: Error | undefined) => void))
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
|
||||
config.mobile = config.mobile || config.auth.creds.registered
|
||||
const ws = new MobileSocket(config)
|
||||
ws.setMaxListeners(0)
|
||||
ws.setMaxListeners?.(0)
|
||||
|
||||
// if not mobile or already registered -> auto connect
|
||||
if(!config.mobile || config.auth.creds.registered) {
|
||||
@@ -188,6 +188,9 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
let helloMsg: proto.IHandshakeMessage = {
|
||||
clientHello: { ephemeral: ephemeralKeyPair.public }
|
||||
}
|
||||
console.log(helloMsg)
|
||||
console.log(Buffer.from(ephemeralKeyPair.public).toString('base64'))
|
||||
console.log(ephemeralKeyPair.public.length)
|
||||
helloMsg = proto.HandshakeMessage.fromObject(helloMsg)
|
||||
|
||||
logger.info({ browser, helloMsg }, 'connected to WA')
|
||||
@@ -627,7 +630,7 @@ function mapWebSocketError(handler: (err: Error) => void) {
|
||||
return (error: Error) => {
|
||||
handler(
|
||||
new Boom(
|
||||
`WebSocket Error (${error.message})`,
|
||||
`WebSocket Error (${error?.message})`,
|
||||
{ statusCode: getCodeFromWSError(error), data: error }
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user