* Called on `drain` event * * @private
()
| 675 | * @private |
| 676 | */ |
| 677 | private _onDrain() { |
| 678 | this.writeBuffer.splice(0, this._prevBufferLen); |
| 679 | |
| 680 | // setting prevBufferLen = 0 is very important |
| 681 | // for example, when upgrading, upgrade packet is sent over, |
| 682 | // and a nonzero prevBufferLen could cause problems on `drain` |
| 683 | this._prevBufferLen = 0; |
| 684 | |
| 685 | if (0 === this.writeBuffer.length) { |
| 686 | this.emitReserved("drain"); |
| 687 | } else { |
| 688 | this.flush(); |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | /** |
| 693 | * Flush write buffers. |