flush method

void flush()

Attempts to flush the packets buffer.

Implementation

void flush() {
  if ('closed' != readyState &&
      transport.writable == true &&
      writeBuffer.isNotEmpty) {
    emit('flush', writeBuffer);
    server.emit('flush', [this, writeBuffer]);
    var wbuf = writeBuffer;
    writeBuffer = [];
    if (transport.supportsFraming == false) {
      sentCallbackFn.add((_) {
        for (var packetFn in packetsFn) {
          packetFn(_);
        }
      });
    } else {
      sentCallbackFn.addAll(packetsFn);
    }
    packetsFn = [];
    transport.send(wbuf);
    emit('drain');
    server.emit('drain', this);
  }
}