As the subject says - can you add multiple elements of the same type to a datagram? Or do you have to send 2 datagrams to do that?
datagram = Datagram()
datagram.addString("This is the first string")
datagram.addString("This is the second string")
datagram1 = Datagram()
datagram1.addString("This is the first string")
datagram2 = Datagram()
datagram2.addString("This is the second string")
If you can add multiple elements of the same type, is there some way to distinguish the order in which they were added?
Question 2 - can you send an array in a datagram? Maybe through the appendData function?
it is possible to add several elements of the same type into one Datagram… but as far as I know you need to know the order of the strings or ints and so on…
For that I have in the beginning of every datagram a key string like “position” or “hit”. Then I have a strict order of the following elements… but a way to distinguish the order would be useful for me too =)
Distinguishing the order may be a pain but on the other hand there’s no constraints to follow in order to use Panda which make it flexible.
One advice here (that might look stupid at first read) is to write down every network message you are sending on two paper-sheets (one for outgoing and an other for incoming messages). Otherwhise, you’ll quickly turn nuts!
A second one will be to construct small and finite datagrams. The size of a datagram and the number of data you do add doesn’t matter (you can put 5 strings in a datagram without problem) but you’ll quickly see that you’ll need to adjust them by adding one Int here or one String there…
Also, as a personnal choice, I avoid arrays and do prefer construct datagrams with most basic data at source. You’ll loose some time to destruct/rebuilt your data but at least you precisely know what’s in the network flow…
My two cents
Thanks folks, got the answers I was looking for. Now I just to see if I can make it work