onkelv onkelv - 1 year ago 99
C# Question

Emitted jsonmessage from Unity to nodejs using Unity-socketio-websocketsharp can not be parsed

I try to send a json message using the emit method from the

library but the received message can not be parsed.

socket.Emit("data", "{\"name\":\"data\",\"args\":[{\"name\":\"testvariable1\",\"value\":\"-63\"}]}");

The connection can be build up and I can also receive messages from

The debug output from nodejs looks like this where the [args] argument stays empty:

debug - websocket writing 5:::{"name":"data","args":[{}]}

Answer Source

So i got it working not with the emit method but with the send method:

EventMessage evm = new EventMessage();
evm.Event = "data";
evm.MessageText = "{\"name\":\"data\",\"args\":[{\"name\":\"testvariable1\",\"value\": -63}]}";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download