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":[{}]}

2
  • 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? Commented Sep 18, 2016 at 6:04
  • Yes the receiving side can work with negative values. What exactly do you mean with a simple json? Commented Sep 18, 2016 at 8:26

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.