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}) {
final goodbye =
Goodbye(GoodbyeMessage(message), Goodbye.reasonGoodbyeAndOut);
_transport.send(goodbye);
if (timeout != null) {
return Future.delayed(timeout, () => _transport.close());
}
return Future.value();
}