closeStreamingConnection method
Closes the streaming connection if it is open.
Implementation
Future<void> closeStreamingConnection() async {
await _webSocket?.sink.close();
_webSocket = null;
_cancelConnectionTimer();
// Hack for dart:io version of websocket to get time to close the stream
// in _listenToWebSocket
await Future.delayed(const Duration(milliseconds: 100));
}