@gudhub/core 1.2.4-beta.64 → 1.2.4-beta.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,7 +59,8 @@ export class WebSocketApi {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
async onMessage(event) {
|
|
62
|
-
|
|
62
|
+
// Browser WebSocket passes MessageEvent (data in event.data), Node.js ws passes raw Buffer
|
|
63
|
+
const message = this.isBrowser ? event.data : event.toString()
|
|
63
64
|
if (message.match(/HeartBeat/)) {
|
|
64
65
|
const hartBeatDelay = new Date().getTime() - this.heartBeatTimeStemp;
|
|
65
66
|
|
|
@@ -101,13 +102,13 @@ export class WebSocketApi {
|
|
|
101
102
|
this.websocket.onmessage = this.onMessage.bind(this);
|
|
102
103
|
} else {
|
|
103
104
|
this.websocket = new Websocket(this.url);
|
|
104
|
-
this.websocket.on("open", this.onOpen);
|
|
105
|
+
this.websocket.on("open", this.onOpen.bind(this));
|
|
105
106
|
|
|
106
|
-
this.websocket.on("error", this.onError);
|
|
107
|
+
this.websocket.on("error", this.onError.bind(this));
|
|
107
108
|
|
|
108
|
-
this.websocket.on("close", this.onClose);
|
|
109
|
+
this.websocket.on("close", this.onClose.bind(this));
|
|
109
110
|
|
|
110
|
-
this.websocket.on("message", this.onMessage);
|
|
111
|
+
this.websocket.on("message", this.onMessage.bind(this));
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
console.log("websocket initialized");
|