Good day. I can not find how to organize data exchange on websocket in a unit in a json-format. Tell me please.
I figured out how to connect a web socket, but I can’t find how to process the received message which is in standard json format.
Good day. I can not find how to organize data exchange on websocket in a unit in a json-format. Tell me please.
I figured out how to connect a web socket, but I can’t find how to process the received message which is in standard json format.
Unity has a special utility ( JsonUtility ) for working with jones.
You need its FromJson method, which will accept the string sent to you via the socket and return the class you need (well, or try to do it).
string json = //тут вы формирует его из полученных байтов MyClass class = JsonUtility.FromJson<MyClass>(json); if (class != null) { class.DoCool("Мы сделали это!"); } else { LogService.PushError("Где json, Лебовски?!"); } Source: https://ru.stackoverflow.com/questions/807817/
All Articles