mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
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:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user