[Unity3D] OnMessage issue with JSON object (SOLVED)
Ipsio last edited by Ipsio
Hi everyone !
I'm working with Unity3D and having an issue with the OnMessage function.
I don't want to send a string but a JSON object.
I actually receive the message but I can't use it in Unity as a System.Object which does not support Indexation.
The following screenshot shows the values in the message received :
Is there a way to access object datas or future Colyseus updates planned for this kind of issue ?
There's actually no JSON being transported from client to server and vice-versa. It's all MessagePack.
This is the major hassle currently with the Unity3D client. It's necessary to cast all data types coming from the server.
You'd need to check which data type is being received and cast
e.messageto match it. Example:
var message = (IndexedDictionary<string, object>) e.message; message["id"] // => "T2"
I'm using the msgpack-unity3d to handle the incoming messages from the server. Maybe there's an easier alternative out there?
Hope this helps. Cheers!
Ipsio last edited by
thank you for the quick answer.
Indeed, I finally manage to make it work with data casting but I'll take a look at the msgpack !
Thanks a lot !