fix: socket.io v3/v4 incomming message issue (#2811)

This commit is contained in:
Oliver Zhou (毓杰)
2022-10-22 15:01:31 +08:00
committed by GitHub
parent b587e21c90
commit b61df04c1b

View File

@@ -32,7 +32,11 @@ export class SIOClientV4 implements SIOClient {
}
on(event: PossibleEvent, cb: (data: any) => void) {
this.client?.on(event, cb)
if (event === "*") {
this.client?.onAny((...data) => {
cb({ data })
})
} else this.client?.on(event, cb)
}
emit(event: string, data: any, cb: (data: any) => void): void {
@@ -51,7 +55,11 @@ export class SIOClientV3 implements SIOClient {
}
on(event: PossibleEvent, cb: (data: any) => void): void {
this.client?.on(event, cb)
if (event === "*") {
this.client?.onAny((...data) => {
cb({ data })
})
} else this.client?.on(event, cb)
}
emit(event: string, data: any, cb: (data: any) => void): void {