MCPcopy
hub / github.com/socketio/socket.io / send

Method send

packages/engine.io/lib/transports/websocket.ts:45–68  ·  view source on GitHub ↗
(packets: Packet[])

Source from the content-addressed store, hash-verified

43 }
44
45 send(packets: Packet[]) {
46 this.writable = false;
47
48 for (let i = 0; i < packets.length; i++) {
49 const packet = packets[i];
50 const isLast = i + 1 === packets.length;
51
52 if (this._canSendPreEncodedFrame(packet)) {
53 // the WebSocket frame was computed with WebSocket.Sender.frame()
54 // see https://github.com/websockets/ws/issues/617#issuecomment-283002469
55 // @ts-expect-error use of untyped member
56 this.socket._sender.sendFrame(
57 packet.options.wsPreEncodedFrame,
58 isLast ? this._onSentLast : this._onSent,
59 );
60 } else {
61 this.parser.encodePacket(
62 packet,
63 this.supportsBinary,
64 isLast ? this._doSendLast : this._doSend,
65 );
66 }
67 }
68 }
69
70 /**
71 * Whether the encoding of the WebSocket frame can be skipped.

Callers 1

WebSocketClass · 0.45

Calls 1

Tested by

no test coverage detected