Chen.Gaowei Posted February 27, 2013 Share Posted February 27, 2013 Hi, I am working on a networking module using Unigine. I would like to send a Xml buffer data over the network using the Unigine::Variable class because I use SharedData class to serialize and deserialize the data. My usage is like the following: On the sender side: SharedData cmd = new SharedData(); Xml xml = new Xml(); engine.editor.saveUserWorldNode(xml, node); cmd.addFiled(xml); network.send(cmd); On the receiver side: typeid(cmd.getNextField()) I get a 0, which means it is an int type. I am wondering how to cast a Xml to a Unigine::Variable, by looking at the source code, it seems like it supports custom class, but I have no clue how to use it. I would really appreciate if someone can help me out with this. Thanks! Luke (Gaowei Chen) email: luke19861025@hotmail.com Link to comment
ulf.schroeter Posted February 27, 2013 Share Posted February 27, 2013 If I remember correctly SharedData only supports UNIGINE base types like string, mat4 etc. I guess you have to convert xml to string variable via xml::getSubTree() before sending and than use xml::parse() after receptionhttps://developer.unigine.com/en/docs/1.0/code/scripting/core/class.xml Link to comment
Chen.Gaowei Posted February 27, 2013 Author Share Posted February 27, 2013 Okay, I get it. Thanks. Link to comment
ulf.schroeter Posted February 27, 2013 Share Posted February 27, 2013 BTW depending of the amount of data you are planing to send via network xml might not be the most efficient approach as this incures quite some overhead for conversion and network bandwidth. Link to comment
frustum Posted February 27, 2013 Share Posted February 27, 2013 I don't recommend to use Network plugin functionality. This code is not supported. You can use Buffer class to write any data types into them. You can use /data/core/syncker/* as an example. Link to comment
Chen.Gaowei Posted March 1, 2013 Author Share Posted March 1, 2013 BTW depending of the amount of data you are planing to send via network xml might not be the most efficient approach as this incures quite some overhead for conversion and network bandwidth. You're definitely correct about it. Well the reason I am trying to send the xml data is because our project involves lots of nodes synchronization, and we do save them as .node files. But I realize that since the unigine core can save the node data into a stream using save_state function, I suppose I should be able to save a node into a Buffer stream and send the buffer over the network. This probably would be the most convenient way to do it. Link to comment
Chen.Gaowei Posted March 1, 2013 Author Share Posted March 1, 2013 I don't recommend to use Network plugin functionality. This code is not supported. You can use Buffer class to write any data types into them. You can use /data/core/syncker/* as an example. Got it, thanks a lot! Link to comment
Recommended Posts