sendText method

  1. @override
void sendText(
  1. String s
)

Sends text data to the connected peer.

Throws WebSocketConnectionClosed if the WebSocket is closed (either through close or by the peer).

Data sent through sendText will be silently discarded if the peer is disconnected but the disconnect has not yet been detected.

Implementation

@override
void sendText(String s) {
  if (_events.isClosed) {
    throw WebSocketConnectionClosed();
  }
  _task
      .sendMessage(URLSessionWebSocketMessage.fromString(s))
      .then((_) => _, onError: _closeConnectionWithError);
}