46 lines
1015 B
C++
46 lines
1015 B
C++
#ifndef CDUTILS_PROTOCOL_H
|
|
#define CDUTILS_PROTOCOL_H
|
|
|
|
#include "pibytearray.h"
|
|
|
|
namespace CDUtils {
|
|
|
|
enum CDPacketType {CD_Ping,
|
|
CD_Pong,
|
|
|
|
CD_KQuery,
|
|
CD_KSend,
|
|
CD_KDirectChange,
|
|
|
|
CD_XQuery,
|
|
CD_XSend,
|
|
CD_XValues,
|
|
|
|
CD_Command,
|
|
};
|
|
|
|
# pragma pack(push,1)
|
|
|
|
struct PacketHeader {
|
|
int type; // CDPacketType
|
|
int session_id;
|
|
};
|
|
|
|
struct PacketKDirectChange {
|
|
PIDeque<int> path;
|
|
PIString value;
|
|
};
|
|
|
|
# pragma pack(pop)
|
|
|
|
|
|
inline PIByteArray & operator <<(PIByteArray & s, const PacketHeader & v) {s << v.type << v.session_id; return s;}
|
|
inline PIByteArray & operator >>(PIByteArray & s, PacketHeader & v) {s >> v.type >> v.session_id; return s;}
|
|
|
|
inline PIByteArray & operator <<(PIByteArray & s, const PacketKDirectChange & v) {s << v.path << v.value; return s;}
|
|
inline PIByteArray & operator >>(PIByteArray & s, PacketKDirectChange & v) {s >> v.path >> v.value; return s;}
|
|
|
|
}
|
|
|
|
#endif // CDUTILS_PROTOCOL_H
|