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

Method send

packages/engine.io/lib/transports-uws/polling.ts:259–285  ·  view source on GitHub ↗

* Writes a packet payload. * * @param {Object} packet * @private

(packets)

Source from the content-addressed store, hash-verified

257 * @private
258 */
259 send(packets) {
260 this.writable = false;
261
262 if (this.shouldClose) {
263 debug("appending close packet to payload");
264 packets.push({ type: "close" });
265 this.shouldClose();
266 this.shouldClose = null;
267 }
268
269 const doWrite = (data: string) => {
270 const compress = packets.some((packet) => {
271 return packet.options && packet.options.compress;
272 });
273 this.write(data, { compress });
274 };
275
276 if (this.protocol === 3) {
277 (this.parser as typeof parser_v3).encodePayload(
278 packets,
279 this.supportsBinary,
280 doWrite,
281 );
282 } else {
283 (this.parser as typeof parser_v4).encodePayload(packets, doWrite);
284 }
285 }
286
287 /**
288 * 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