git-svn-id: svn://db.shs.com.ru/libs@586 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
53
test/cd_utils/cdutils_protocol.h
Normal file
53
test/cd_utils/cdutils_protocol.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#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_XRequest,
|
||||
CD_XValues,
|
||||
|
||||
CD_CQuery,
|
||||
CD_CSend,
|
||||
CD_Command,
|
||||
|
||||
CD_MQuery,
|
||||
CD_MSend,
|
||||
CD_Message,
|
||||
};
|
||||
|
||||
# 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
|
||||
Reference in New Issue
Block a user