close method
Closes the WebSocket connection.
Implementation
Future<void> close() async {
try {
await _wsSubscription.cancel().timeout(const Duration(seconds: 1),
onTimeout: () {
log('live_session.close: cancel timed out',
error: TimeoutException('Cancel timed out'));
});
if (!_messageController.isClosed) {
await _messageController.close();
}
await _ws.sink.close().timeout(const Duration(seconds: 1), onTimeout: () {
log('live_session.close: sink close timed out',
error: TimeoutException('Sink close timed out'));
});
} catch (e) {
log('live_session.close: error during close', error: e);
}
}