close method

Future<void> close({
  1. String message = 'Regular closing',
  2. Duration? timeout,
})

Sends a goodbye message and closes the transport after a given timeout. If no timeout is set, the client waits for the server to close the transport forever.

Implementation

Future<void> close({String message = 'Regular closing', Duration? timeout}) {
  final goodbye =
      Goodbye(GoodbyeMessage(message), Goodbye.reasonGoodbyeAndOut);
  _transport.send(goodbye);
  if (timeout != null) {
    return Future.delayed(timeout, () => _transport.close());
  }
  return Future.value();
}