close method
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,
}) {
if (_goodbyeSent) {
return Future<void>.value();
}
_goodbyeSent = true;
_transport.send(
Goodbye(GoodbyeMessage(message), Goodbye.reasonNormal),
);
if (timeout != null) {
return Future.delayed(timeout, () => _transport.close());
}
return Future<void>.value();
}