I have packet like this
class Packet {
private $DATASize;
private $signature;
private $version;
private $HSIZE;
private $SessionIDUser1;
private $SessionIDUser2;
}
I'm using UDP protocol.
Since there is no methods in this class, you can encode the instance with
json_encode
and send him as a string. on the client side just decode and clone. it can be done also when the class have methods, with more complication.Example:
Edit:
Now i see that your fields are
private
, so you need implement method for json encoding. see https://stackoverflow.com/a/7005915/2075420 and https://stackoverflow.com/a/9942303/2075420.