* Attempts to flush the packets buffer. * * @private
()
| 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. |