Jump to content

[SOLVED] how to make a Xml class as a Variable?


photo

Recommended Posts

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

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

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

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

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
×
×
  • Create New...