1

I try to send a json message using the emit method from the unitysocketio-websocketsharp 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 nodejs.

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

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

Shorty123
  • 539
  • 1
  • 7
  • 26
  • You are sending the negative value as a String. Are you prepared for that on the receiving side? Also, if you send a simple json, does the parsing work? – JSONStatham Sep 18 '16 at 06:04
  • Yes the receiving side can work with negative values. What exactly do you mean with a simple json? – Shorty123 Sep 18 '16 at 08:26

1 Answers1

1

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}]}";
socket.Send(evm);
Shorty123
  • 539
  • 1
  • 7
  • 26