* 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)
| 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. |
no test coverage detected