Skip to content

Commit ef1c4c8

Browse files
refactor: remove the wsPreEncoded option
The wsPreEncoded option was added in the `socket.io-adapter` package when broadcasting a message to multiple clients. It was removed in [1] and is now superseded by the `wsPreEncodedFrame` option, which directly computes the WebSocket frame once for all clients (see [2]). [1]: socketio/socket.io-adapter@88eee59 [2]: socketio/socket.io-adapter@5f7b47d
1 parent 8955eb7 commit ef1c4c8

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

lib/transports/websocket.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ export class WebSocket extends Transport {
8585
this.socket.send(data, opts, onSent);
8686
};
8787

88-
if (packet.options && typeof packet.options.wsPreEncoded === "string") {
89-
send(packet.options.wsPreEncoded);
90-
} else if (this._canSendPreEncodedFrame(packet)) {
88+
if (this._canSendPreEncodedFrame(packet)) {
9189
// the WebSocket frame was computed with WebSocket.Sender.frame()
9290
// see https://github.com/websockets/ws/issues/617#issuecomment-283002469
9391
this.socket._sender.sendFrame(packet.options.wsPreEncodedFrame, onSent);

test/server.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,25 +2889,6 @@ describe("server", () => {
28892889
});
28902890

28912891
describe("pre-encoded content", () => {
2892-
it("should use the pre-encoded content", (done) => {
2893-
engine = listen((port) => {
2894-
client = new ClientSocket(`ws://localhost:${port}`, {
2895-
transports: ["websocket"],
2896-
});
2897-
2898-
engine.on("connection", (conn) => {
2899-
conn.send("test", {
2900-
wsPreEncoded: "4test pre-encoded",
2901-
});
2902-
});
2903-
2904-
client.on("message", (msg) => {
2905-
expect(msg).to.be("test pre-encoded");
2906-
done();
2907-
});
2908-
});
2909-
});
2910-
29112892
it("should use the pre-encoded frame", function (done) {
29122893
if (process.env.EIO_WS_ENGINE === "uws") {
29132894
return this.skip();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy