TransportWSServer constructor

TransportWSServer(
  1. StreamChannel<String> channel, {
  2. required void close(
    1. int code,
    2. String reason
    ),
  3. Duration connectionInitWaitTimeout = const Duration(seconds: 3),
  4. Duration? keepAliveInterval,
})

Implementation

TransportWSServer(
  this.channel, {
  required this.close,
  this.connectionInitWaitTimeout = const Duration(seconds: 3),
  this.keepAliveInterval,
}) {
  _initTimer = Timer(connectionInitWaitTimeout, () {
    if (!_initReceived) {
      _closeWith(
        TransportWSCloseCode.connectionInitialisationTimeout,
        'Connection initialisation timeout',
      );
    }
  });
  _subscription = channel.stream.listen(
    _onText,
    // An error, such as a binary message, is an invalid message: the
    // connection is closed, rather than kept open unanswered.
    onError: (_) =>
        _closeWith(TransportWSCloseCode.badRequest, 'Invalid message'),
    onDone: _end,
  );
}