The most effective way would be to send and receive raw byte arrays.
I’d recommend starting each byte array with an identifying byte, which tells the recipient what the packet is for and then follow with the data.
I’m guessing that those “/d/”-like strings are separators, but it would be more efficient for the recipient to know how long everything in the array is, so bytes aren’t wasted on separators.
If you send strings, the recipient has to do the following:
- Convert the byte array into a String
- Split the String
- Parse any Integers or Shorts etc
If you use raw byte arrays, the recipient has to do the following:
- Extract each piece of data from the array
- Convert some of it into things like Integers or Shorts etc
Below is an example of my favourite approach.
Say you want to tell the server that you are placing a card into your deck. Assuming that there are under 257 cards in your hand and less than 257 slots in your deck, I’d structure the packet to only use 3 bytes like this:
1x Identifying byte | 1x (short) Card Position in Hand | 1x (short) Position in Deck