Dear @mstoykov,
I use the following code instead and it can do the “go install”.
func (s *Socket) SendBinary(writeData byte) {
// NOTE: No binary message support for the time being since goja doesn’t
// support typed arrays.
rt := common.GetRuntime(s.ctx)
if err := s.conn.WriteMessage(websocket.BinaryMessage, writeData); err != nil {
s.handleEvent("error", rt.ToValue(err))
}
stats.PushIfNotDone(s.ctx, s.samplesOutput, stats.Sample{
Metric: metrics.WSMessagesSent,
Time: time.Now(),
Tags: s.sampleTags,
Value: 1,
})
}
But when I call the sendBinary(message) method, it throw the following error. My message’s type is Uint8Array which is returned by google protobuf js. How can I resolve this issue? Really appreciate ur great help in advance!
socket.sendBinary(message_proto.serializeBinary());
ERRO[0001] TypeError: Could not convert function call parameter 24,184,181,178,181,161,46,34,11,99,108,97,117,100,105,111,55,55,55,55 to uint8
at native
The following is message_proto.serializeBinary() method
/**
- Serializes the message to binary data (in protobuf wire format).
- @return {!Uint8Array}
*/
proto.ControlMessage.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.ControlMessage.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
Thanks,
Roy