-
Notifications
You must be signed in to change notification settings - Fork 27
CPacket
The CPacket class represents a packet transfered via the network. A packet contains one command and its corresponding parameters (possibly empty). For asynchronized communication, the sender simply sends notification (TYPE_NOTIFICATION) packets. For synchronized communication, the sender waits for a reply (TYPE_REPLY) packet after sending a request (TYPE_REQUEST) packet.
enum Type {TYPE_NOTIFICATION, TYPE_REQUEST, TYPE_REPLY};
CPacket();
CPacket(int command, Type type);
CPacket(const CPacket &source);
~CPacket();
bool isValid() const;
int command() const;
void setCommand(int command);
Type type() const;
void setType(Type type);
void setData(const QVariant &data);
const QVariant &data() const;
void detach();
Creates an invalid packet.
Create a packet and define its command and type.
Copy a packet from an existing packet, source.
Destroys a packet.
Returns true if the packet is valid or false if it's invalid.
Returns the command of the packet.
Sets the command of the packet.
Returns the type of the packet.
Sets the type of the packet.
Sets the data of the packet.
Returns the data of the packet.
CPacket is implicitly shared. Calling void detach() detachs this instance from other owners. That is, copy a new instance so it's ready to be modified.