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]: 88eee5948a
[2]: 5f7b47d40f
This commit is contained in:
Damien Arrachequesne
2024-06-13 23:55:16 +02:00
parent 8955eb7b75
commit ef1c4c8bb7
2 changed files with 1 additions and 22 deletions

View File

@@ -85,9 +85,7 @@ export class WebSocket extends Transport {
this.socket.send(data, opts, onSent);
};
if (packet.options && typeof packet.options.wsPreEncoded === "string") {
send(packet.options.wsPreEncoded);
} else if (this._canSendPreEncodedFrame(packet)) {
if (this._canSendPreEncodedFrame(packet)) {
// the WebSocket frame was computed with WebSocket.Sender.frame()
// see https://github.com/websockets/ws/issues/617#issuecomment-283002469
this.socket._sender.sendFrame(packet.options.wsPreEncodedFrame, onSent);

View File

@@ -2889,25 +2889,6 @@ describe("server", () => {
});
describe("pre-encoded content", () => {
it("should use the pre-encoded content", (done) => {
engine = listen((port) => {
client = new ClientSocket(`ws://localhost:${port}`, {
transports: ["websocket"],
});
engine.on("connection", (conn) => {
conn.send("test", {
wsPreEncoded: "4test pre-encoded",
});
});
client.on("message", (msg) => {
expect(msg).to.be("test pre-encoded");
done();
});
});
});
it("should use the pre-encoded frame", function (done) {
if (process.env.EIO_WS_ENGINE === "uws") {
return this.skip();