onPollRequest method

void onPollRequest(
  1. SocketConnect connect
)

Implementation

void onPollRequest(SocketConnect connect) {
  if (this.connect != null) {
    // assert: this.res, '.req and .res should be (un)set together'
    onError('overlap from client');
    this.connect!.request.response.statusCode = 500;
    this.connect!.close();
    return;
  }

  this.connect = connect;

  onClose() {
    onError('poll connection closed prematurely');
  }

  cleanup() {
    _reqCloses.remove(connect);
    this.connect = null;
  }

  _reqCleanups[connect] = cleanup;
  _reqCloses[connect] = onClose;

  writable = true;
  emit('drain');

  // if we're still writable but had a pending close, trigger an empty send
  if (writable == true && shouldClose != null) {
    send([
      {'type': 'noop'}
    ]);
  }
}