closeStreamingConnection method

  1. @Deprecated('This method was used in the old streaming API and will be removed in future versions. ' 'Use endpoints with stream parameters or return type to resolve the streaming connection status directly.')
Future<void> closeStreamingConnection()

Closes the streaming connection if it is open.

Implementation

@Deprecated(
  'This method was used in the old streaming API and will be removed in future versions. '
  'Use endpoints with stream parameters or return type to resolve the streaming connection status directly.',
)
Future<void> closeStreamingConnection() async {
  await _webSocket?.sink.close();
  _webSocket = null;
  _cancelConnectionTimer();

  // Notify listeners that websocket has been closed
  _notifyWebSocketConnectionStatusListeners();

  // Hack for dart:io version of websocket to get time to close the stream
  // in _listenToWebSocket
  await Future.delayed(const Duration(milliseconds: 100));
}