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

Method flush

packages/engine.io/lib/socket.ts:509–532  ·  view source on GitHub ↗

* Attempts to flush the packets buffer. * * @private

()

Source from the content-addressed store, hash-verified

507 * @private
508 */
509 private flush() {
510 if (
511 "closed" !== this.readyState &&
512 this.transport.writable &&
513 this.writeBuffer.length
514 ) {
515 debug("flushing buffer to transport");
516 this.emit("flush", this.writeBuffer);
517 this.server.emit("flush", this, this.writeBuffer);
518 const wbuf = this.writeBuffer;
519 this.writeBuffer = [];
520
521 if (this.packetsFn.length) {
522 this.sentCallbackFn.push(this.packetsFn);
523 this.packetsFn = [];
524 } else {
525 this.sentCallbackFn.push(null);
526 }
527
528 this.transport.send(wbuf);
529 this.emit("drain");
530 this.server.emit("drain", this);
531 }
532 }
533
534 /**
535 * Get available upgrades for this socket.

Callers 3

onReadyMethod · 0.95
onPacketMethod · 0.95
sendPacketMethod · 0.95

Calls 4

emitMethod · 0.95
debugFunction · 0.85
emitMethod · 0.65
sendMethod · 0.45

Tested by

no test coverage detected