01-06-2018 11:18 AM
I'm reading someone else's code. Can someone kindly please explain the section send command to server . thank you
01-06-2018 11:53 AM - edited 01-06-2018 11:59 AM
Well, the only thing you can send is a raw string and this section of code is used to built that string in a way the receiver expect it to be structured.
This code will blow up if the string length of the ringtext.text +8 is larger than the range of U8, so I would probably replace the upper part by just casting the size to a string (it will be 4 bytes directly). So, after the size you are appending four more fixed bytes followed by the text from the property node.
So the final string will be structured as follows
(the total data size is "String size + 8": 4bytes+4bytes+string)
Most likely, the receiver will read four bytes to determine the size of the rest of the data, then read that. It then will check if the four next bytes are 0001 (e.g. a custom tag, telling the receiver what the data represents: 0001="text of a ring", 0002="array data", etc.) :D), then extract the real payload, the text and send it to the rest of the code for processing.