Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

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

Oliver Zhou (毓杰)b61df04c1ba6
diff --git a/packages/hoppscotch-app/src/helpers/realtime/SIOClients.ts b/packages/hoppscotch-app/src/helpers/realtime/SIOClients.ts
index c0a9fc20e..83f3b25e8 100644
--- a/packages/hoppscotch-app/src/helpers/realtime/SIOClients.ts
+++ b/packages/hoppscotch-app/src/helpers/realtime/SIOClients.ts
@@ -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 {