send method
data: the content. Either a string (json) or Uint8List (binary)
Implementation
@override
Future<void> send(Object data) {
if (_webSocket != null) {
_logger?.finest(
"(WebSockets transport) sending data. ${getDataDetail(data, true)}.");
//_logger?.finest("(WebSockets transport) sending data.");
if (data is String) {
_webSocket!.sink.add(data);
} else if (data is Uint8List) {
_webSocket!.sink.add(data);
} else {
throw GeneralError("Content type is not handled.");
}
return Future.value(null);
}
return Future.error(GeneralError("WebSocket is not in the OPEN state"));
}