How to transfer binary data using websocket, under weex?

the environmental background of the problems and what methods you have tried

before using socket.binaryType = "arraybuffer",
or socket in the native environment of each client supports the transfer of binary data such as protobuf is no problem.
but weex on Android does not provide the implementation of websocket by default. If you need to write your own adapter, humor trick, the provided API IWebSocketAdapter defaults to String,
void send (void String var1) , onMessage (String var1) .
is weex really going to become a KPI thing?
websocket that uses weex on Android requires special treatment? Transfer to base64??-sharp-sharp-sharp problem description

related codes

// js
class ChatController {
  constructor({ socket } = {}) {
    super();
    this.socket = socket;
    this.socket.binaryType = "arraybuffer";
    this.openSocket();
  }
  openSocket() {
    this.socket.WebSocket(wsURL);
    this.socket.onmessage = (data) => this.receive(data);
    this.socket.onopen = (options) => console.log("opened connection");
    this.socket.onerror = (data) => console.error(data);
  }


  send(message) {
    this.socket.send(message);
  }
}

what result do you expect? What is the error message actually seen?

there is no problem when the above code is executed under the browser

clipboard.png

can be processed as {"@ type": "binary", "base64": "", "dataType": "ArrayBuffer"}

in the JAVA code under Android.
// WebSocketAdapter
@Override
    public void send(String data) {
        WXLogUtils.i("WebSocketAdapter", data);
        if (ws != null) {
            try {
                Buffer buffer = new Buffer().writeUtf8(data);
                ws.sendMessage(WebSocket.PayloadType.BINARY, buffer.buffer());
                buffer.flush();
                buffer.close();

                wsEventReporter.frameSent(data);
            } catch (Exception e) {
                e.printStackTrace();
                reportError(e.getMessage());
                wsEventReporter.frameError(e.getMessage());
            }
        } else {
            reportError("WebSocket is not ready");
        }
    }
Apr.11,2021
Menu