GraphQLWsServer constructor

GraphQLWsServer(
  1. GraphQLWsClient client, {
  2. Duration? connectionInitWaitTimeout,
})

Starts serving client.

Implementation

GraphQLWsServer(this.client, {this.connectionInitWaitTimeout}) {
  _sub = client.stream.listen(
    _handle,
    // A frame the protocol cannot read arrives here rather than as an
    // exception nobody catches.
    onError: (Object e) =>
        _closeWith(GraphQLWsCloseCode.badRequest, e.toString()),
    onDone: () => _close(),
  );

  final wait = connectionInitWaitTimeout;
  if (wait != null) {
    _initTimer = Timer(wait, () {
      if (!_init) {
        _closeWith(
          GraphQLWsCloseCode.connectionInitialisationTimeout,
          'Connection initialisation timeout',
        );
      }
    });
  }
}