Skip to content

Commit 64d5754

Browse files
1 parent c0d6eaa commit 64d5754

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

lib/transports/websocket.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export class WebSocket extends Transport {
1616
constructor(req) {
1717
super(req);
1818
this.socket = req.websocket;
19-
this.socket.on("message", this.onData.bind(this));
19+
this.socket.on("message", (data, isBinary) => {
20+
const message = isBinary ? data : data.toString();
21+
debug('received "%s"', message);
22+
super.onData(message);
23+
});
2024
this.socket.once("close", this.onClose.bind(this));
2125
this.socket.on("error", this.onError.bind(this));
2226
this.writable = true;
@@ -50,17 +54,6 @@ export class WebSocket extends Transport {
5054
return true;
5155
}
5256

53-
/**
54-
* Processes the incoming data.
55-
*
56-
* @param {String} encoded packet
57-
* @api private
58-
*/
59-
onData(data) {
60-
debug('received "%s"', data);
61-
super.onData(data);
62-
}
63-
6457
/**
6558
* Writes a packet payload.
6659
*

package-lock.json

Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"cors": "~2.8.5",
3636
"debug": "~4.3.1",
3737
"engine.io-parser": "~5.0.0",
38-
"ws": "~7.4.2"
38+
"ws": "~8.2.3"
3939
},
4040
"devDependencies": {
4141
"babel-eslint": "^8.0.2",

0 commit comments

Comments
 (0)