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

Method send

packages/engine.io/lib/transports/polling.ts:221–247  ·  view source on GitHub ↗
(packets: Packet[])

Source from the content-addressed store, hash-verified

219 }
220
221 send(packets: Packet[]) {
222 this.writable = false;
223
224 if (this.shouldClose) {
225 debug("appending close packet to payload");
226 packets.push({ type: "close" });
227 this.shouldClose();
228 this.shouldClose = null;
229 }
230
231 const doWrite = (data: string) => {
232 const compress = packets.some((packet) => {
233 return packet.options && packet.options.compress;
234 });
235 this.write(data, { compress });
236 };
237
238 if (this.protocol === 3) {
239 (this.parser as typeof parser_v3).encodePayload(
240 packets,
241 this.supportsBinary,
242 doWrite,
243 );
244 } else {
245 (this.parser as typeof parser_v4).encodePayload(packets, doWrite);
246 }
247 }
248
249 /**
250 * Writes data as response to poll request.

Callers 3

onPollRequestMethod · 0.95
onCloseMethod · 0.95
doCloseMethod · 0.95

Calls 1

debugFunction · 0.85

Tested by

no test coverage detected