My Flutter app uses a web socket to send the mp3 file to the server directly. I need to slice mp3 file to small ByteBuffer. I use web_socket_channel but when I send ByteBuffer, the _channel onDone immediately and the server has not received data from the app.
void sendData(ByteBuffer data) {
_channel.sink.add(data);
}
listenToMessage() {
if (_channel != null) {
_channel.stream.listen(
(message) {
print("websocket listen: $message");
},
onDone: () {
print("Websocket listen onDone");
},
);
}
}
I saw method sendByteBuffer in Websocket in dart:html lib, but cannot use in the mobile app.