I have following code:
var packet = "\xFF\xFF\xFF\xFF";
packet += "\x6D";
packet += "127.0.0.1:" + this.port;
packet += "\x00";
packet += this.name;
packet += "\x00";
packet += this.state;
packet += "\x00";
packet += "stateA";
packet += "\x00";
packet += "sender";
packet += "\x00";
And I have var id = 32;
I want to get something like this:
...
packet += "\x00";
packet += "sender";
packet += "\x00";
packet += "\x20;
How to convert id
number to HEX format and then concatenate it with packet
?
I already saw Google, but I haven't found a solution.
Thank you.