Open mschrupp opened 9 years ago
You may do it like this:
config.setJsonSupport(new JacksonJsonSupport(config) {
@Override
protected void init(ObjectMapper objectMapper) {
super.init(objectMapper);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
}
});
Does netty-socketio support binary within complex objects?
Yes. Check BinaryEventLauncher in netty-socketio-demo project
@jesusofsuburbia try this, maybe it will help you
function arrayBufferToBase64 (buffer) {
var binary = '';
var bytes = new Uint8Array(buffer);
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
var myData = new Float32Array([0.0, 1.1, 2.2, 3.3]).buffer;
socket.emit('msg', arrayBufferToBase64(myData));
although, this is unlikely to help you :)
@tselishev-semen thought about that already, but thanks alot anyway :+1:
@mrniko I know about the netty-socketio-demo project, but where can I see embedded binary in javascript objects there?
like
{
data : new Float32Array().buffer,
id : "somestring"
}
And thanks for the JacksonJsonSupport example provided above, currently trying to do this! :+1:
Hi guys,
nice work you did here. Thank you so much!!
Anyway, I stumbled upon a problem and really need some help. I'm currently trying to pass a Float32Array from Javascript to Java.
The following error occurs:
I searched for the code where the exception happens, and you can find the following there:
I think I have to enable this
DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY
. The Float32Array seems to be interpreted as a "single value" by the deserializer. You can get the JacksonJsonSupport fromcom.corundumstudio.socketio.Configuration
, but there is no chance to change the Features there, they are hardcoded in theinit()
:... and also private.
Any idea or help on this? Do I need to fork? Is the problem somewhere else, maybe in my JavaScript? The strange thing is, with
Uint8Array
(JavaScript) tobyte[]
(Java) it works without a problem.So here is the code I use in Javascript:
Finally: Does netty-socketio support binary within complex objects? It does not work with custom object in
addEventListener
, set function fails withConflicting setter definitions for property
This is the syntax as supported by socket.io: