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

Method _drainQueue

packages/socket.io-client/lib/socket.ts:581–599  ·  view source on GitHub ↗

* Send the first packet of the queue, and wait for an acknowledgement from the server. * @param force - whether to resend a packet that has not been acknowledged yet * * @private

(force = false)

Source from the content-addressed store, hash-verified

579 * @private
580 */
581 private _drainQueue(force = false) {
582 debug("draining queue");
583 if (!this.connected || this._queue.length === 0) {
584 return;
585 }
586 const packet = this._queue[0];
587 if (packet.pending && !force) {
588 debug(
589 "packet [%d] has already been sent and is waiting for an ack",
590 packet.id,
591 );
592 return;
593 }
594 packet.pending = true;
595 packet.tryCount++;
596 debug("sending packet [%d] (try n°%d)", packet.id, packet.tryCount);
597 this.flags = packet.flags;
598 this.emit.apply(this, packet.args);
599 }
600
601 /**
602 * Sends a packet.

Callers 3

_addToQueueMethod · 0.95
onconnectMethod · 0.95
socket.io.jsFile · 0.80

Calls 2

debugFunction · 0.85
applyMethod · 0.80

Tested by

no test coverage detected