send method

  1. @override
Future<void> send(
  1. dynamic message
)
override

Sends a message to the web socket.

Implementation

@override
Future<void> send(dynamic message) {
  switch (_state) {
    case WebSocketClientState.failed:
    case WebSocketClientState.disconnected:
    case WebSocketClientState.closed:
      return Future.error(StateError(
          "WebSocketClient: cannot send message in $_state state"));

    case WebSocketClientState.connecting:
      return _socketChannel!.ready.then((value) => _send(message));

    case WebSocketClientState.connected:
      _send(message);
      return Future.value();
  }
}