提交 a6724a22 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

uing qt int defs instead of platform specified int macros.

上级 bc1f3eb5
#ifndef CROSS_SVR_MESSAGES_H #ifndef CROSS_SVR_MESSAGES_H
#define CROSS_SVR_MESSAGES_H #define CROSS_SVR_MESSAGES_H
#include <qglobal.h>
namespace ZP_Cluster{ namespace ZP_Cluster{
#pragma pack (push,1) #pragma pack (push,1)
#if defined(__GNUC__)
#include <stdint.h>
typedef struct tag_cross_svr_message{
struct tag_header{
__UINT16_TYPE__ Mark; //Always be "0x1234"
__UINT8_TYPE__ messagetype;
__INT32_TYPE__ data_length;
} hearder;
union uni_payload{
__UINT8_TYPE__ data[1];
struct tag_CSM_heartBeating{
__UINT32_TYPE__ nClients;
} heartBeating;
struct tag_CSM_BasicInfo{
__UINT8_TYPE__ name [64];
__UINT8_TYPE__ Address_LAN[64];
__UINT16_TYPE__ port_LAN;
__UINT8_TYPE__ Address_Pub[64];
__UINT16_TYPE__ port_Pub;
} basicInfo; //msgType 0x01
struct tag_CSM_Broadcast{
__UINT8_TYPE__ name [64];
__UINT8_TYPE__ Address_LAN[64];
__UINT16_TYPE__ port_LAN;
__UINT8_TYPE__ Address_Pub[64];
__UINT16_TYPE__ port_Pub;
}broadcastMsg[1];//msgType 0x02
} payload;
} CROSS_SVR_MSG;
#endif
#if defined(_MSC_VER)
typedef struct tag_cross_svr_message{ typedef struct tag_cross_svr_message{
struct tag_header{ struct tag_header{
unsigned __int16 Mark; //Always be 0x1234 quint16 Mark; //Always be 0x1234
unsigned __int8 messagetype; quint8 messagetype;
__int32 data_length; quint32 data_length;
} hearder; } hearder;
union uni_payload{ union uni_payload{
unsigned __int8 data[1]; quint8 data[1];
struct tag_CSM_heartBeating{ struct tag_CSM_heartBeating{
unsigned __int32 nClients; quint32 nClients;
} heartBeating; } heartBeating;
struct tag_CSM_BasicInfo{ struct tag_CSM_BasicInfo{
unsigned __int8 name [64]; quint8 name [64];
unsigned __int8 Address_LAN[64]; quint8 Address_LAN[64];
unsigned __int16 port_LAN; quint16 port_LAN;
unsigned __int8 Address_Pub[64]; quint8 Address_Pub[64];
unsigned __int16 port_Pub; quint16 port_Pub;
} basicInfo; } basicInfo;
struct tag_CSM_Broadcast{ struct tag_CSM_Broadcast{
unsigned __int8 name [64]; quint8 name [64];
unsigned __int8 Address_LAN[64]; quint8 Address_LAN[64];
unsigned __int16 port_LAN; quint16 port_LAN;
unsigned __int8 Address_Pub[64]; quint8 Address_Pub[64];
unsigned __int16 port_Pub; quint16 port_Pub;
} broadcastMsg[1]; } broadcastMsg[1];
} payload; } payload;
} CROSS_SVR_MSG; } CROSS_SVR_MSG;
#endif
#pragma pack(pop) #pragma pack(pop)
} }
......
#ifndef ST_MESSAGE_H #ifndef ST_MESSAGE_H
#define ST_MESSAGE_H #define ST_MESSAGE_H
#include <qglobal.h>
namespace ExampleServer{ namespace ExampleServer{
#pragma pack (push,1) #pragma pack (push,1)
#if defined(__GNUC__)
#include <stdint.h>
/**
* @brief this structure provides a basic trans blocks.
*
*/
typedef struct tag_example_message{ typedef struct tag_example_message{
__UINT16_TYPE__ Mark; //Always be "0xAA55" quint16 Mark; //Always be 0xAA55
__UINT32_TYPE__ source_id ; //0xffffffff means from server quint32 source_id ; //0xffffffff means from server
__UINT32_TYPE__ destin_id ; //0xffffffff means to server quint32 destin_id ; //0xffffffff means to server
__UINT16_TYPE__ data_length; //Data at least have 2 byte, for heart-beating counter. quint16 data_length; //Data at least have 2 byte, for heart-beating counter.
__UINT8_TYPE__ data[1]; quint8 data[1];
} EXAMPLE_TRANS_MSG; } EXAMPLE_TRANS_MSG;
typedef struct tag_example_heartBeating typedef struct tag_example_heartBeating
{ {
__UINT16_TYPE__ Mark; //Always be 0xBeBe quint16 Mark; //Always be 0xBeBe
__UINT32_TYPE__ source_id ; //0xffffffff means from server quint32 source_id ; //0xffffffff means from server
__UINT16_TYPE__ tmStamp; quint16 tmStamp;
} EXAMPLE_HEARTBEATING; } EXAMPLE_HEARTBEATING;
#endif
#if defined(_MSC_VER)
typedef struct tag_example_message{
unsigned __int16 Mark; //Always be 0xAA55
unsigned __int32 source_id ; //0xffffffff means from server
unsigned __int32 destin_id ; //0xffffffff means to server
unsigned __int16 data_length; //Data at least have 2 byte, for heart-beating counter.
unsigned __int8 data[1];
} EXAMPLE_TRANS_MSG;
typedef struct tag_example_heartBeating
{
unsigned __int16 Mark; //Always be 0xBeBe
unsigned __int32 source_id ; //0xffffffff means from server
unsigned __int16 tmStamp;
} EXAMPLE_HEARTBEATING;
#endif
#pragma pack(pop) #pragma pack(pop)
} }
......
#ifndef ST_MSG_APPLAYER_H #ifndef ST_MSG_APPLAYER_H
#define ST_MSG_APPLAYER_H #define ST_MSG_APPLAYER_H
#include <qglobal.h>
namespace ExampleServer{ namespace ExampleServer{
#pragma pack (push,1) #pragma pack (push,1)
#if defined(__GNUC__)
#include <stdint.h>
//User Login request //User Login request
//SMARTLINK_MSG_APP::MsgType = 0x0001 //SMARTLINK_MSG_APP::MsgType = 0x0001
typedef struct tag_stMsg_ClientLoginReq{ typedef struct tag_stMsg_ClientLoginReq{
__UINT32_TYPE__ user_id; quint32 user_id;
char Passwd[1]; char Passwd[1];
}stMsg_ClientLoginReq; }stMsg_ClientLoginReq;
//User Log response //User Log response
//SMARTLINK_MSG_APP::MsgType = 0x7FFE //SMARTLINK_MSG_APP::MsgType = 0x7FFE
typedef struct tag_stMsg_ClientLoginRsp{ typedef struct tag_stMsg_ClientLoginRsp{
__UINT8_TYPE__ DoneCode; quint8 DoneCode; //0- successful, 1-redirect, 3-failed.
__UINT32_TYPE__ UserID; quint32 UserID;
__UINT8_TYPE__ Address_Redirect[64];// for server-cluster balance, may be this login should be re-direct to another address quint8 Address_Redirect[64];// for server-cluster balance, may be this login should be re-direct to another address
__UINT16_TYPE__ port_Redirect; // and a port num. quint16 port_Redirect; // and a port num.
} stMsg_ClientLoginRsp; } stMsg_ClientLoginRsp;
//0x1002 //0x1002
...@@ -31,94 +28,19 @@ namespace ExampleServer{ ...@@ -31,94 +28,19 @@ namespace ExampleServer{
//0x7FFD //0x7FFD
typedef struct tag_stMsg_ClientLogoutRsp{ typedef struct tag_stMsg_ClientLogoutRsp{
__UINT8_TYPE__ DoneCode; quint8 DoneCode;
}stMsg_ClientLogoutRsp; }stMsg_ClientLogoutRsp;
//UploadUserListReq,0x1003 //UploadUserListReq,0x1003
typedef struct tag_stMsg_UploadUserListReq{ typedef struct tag_stMsg_UploadUserListReq{
__UINT16_TYPE__ UserNum; quint16 UserNum;
__UINT32_TYPE__ pUserIDList[1]; quint32 pUserIDList[1];
}stMsg_UploadUserListReq; }stMsg_UploadUserListReq;
//User Log response //User Log response
//SMARTLINK_MSG_APP::MsgType = 0x7FFC //SMARTLINK_MSG_APP::MsgType = 0x7FFC
typedef struct tag_stMsg_UploadUserListRsp{ typedef struct tag_stMsg_UploadUserListRsp{
__UINT8_TYPE__ DoneCode; quint8 DoneCode;
} stMsg_UploadUserListRsp;
//SMARTLINK_MSG_APP::MsgType = 0x1004
typedef struct tag_stMsg_DownloadUserListReq{
} stMsg_DownloadUserListReq;
//SMARTLINK_MSG_APP::MsgType = 0x7FFB
typedef struct tag_stMsg_DownloadUserListRsp{
__UINT8_TYPE__ DoneCode;
__UINT16_TYPE__ UserNum;
__UINT32_TYPE__ pUserIDList[1];
} stMsg_DownloadUserListRsp;
typedef struct tag_example_app_layer{
struct tag_app_layer_header{
__UINT16_TYPE__ MsgType;
} header;
union union_MsgUnion
{
stMsg_ClientLoginReq msg_ClientLoginReq;
stMsg_ClientLoginRsp msg_ClientLoginRsp;
stMsg_UploadUserListReq msg_UploadUserListReq;
stMsg_UploadUserListRsp msg_UploadUserListRsp;
stMsg_DownloadUserListReq msg_DownloadUserListReq;
stMsg_DownloadUserListRsp msg_DownloadUserListRsp;
stMsg_ClientLogoutReq msg_ClientLogoutReq;
stMsg_ClientLogoutRsp msg_ClientLogoutRsp;
}MsgUnion;
} EXAMPLE_MSG_APP;
#endif
#if defined(_MSC_VER)
//User Login request
//SMARTLINK_MSG_APP::MsgType = 0x0001
typedef struct tag_stMsg_ClientLoginReq{
unsigned __int32 user_id;
char Passwd[1];
}stMsg_ClientLoginReq;
//User Log response
//SMARTLINK_MSG_APP::MsgType = 0x7FFE
typedef struct tag_stMsg_ClientLoginRsp{
unsigned __int8 DoneCode; //0- successful, 1-redirect, 3-failed.
unsigned __int32 UserID;
unsigned __int8 Address_Redirect[64];// for server-cluster balance, may be this login should be re-direct to another address
unsigned __int16 port_Redirect; // and a port num.
} stMsg_ClientLoginRsp;
//0x1002
typedef struct tag_stMsg_ClientLogoutReq{
char UserName[1];//max 32
}stMsg_ClientLogoutReq;
//0x7FFD
typedef struct tag_stMsg_ClientLogoutRsp{
unsigned __int8 DoneCode;
}stMsg_ClientLogoutRsp;
//UploadUserListReq,0x1003
typedef struct tag_stMsg_UploadUserListReq{
unsigned __int16 UserNum;
unsigned __int32 pUserIDList[1];
}stMsg_UploadUserListReq;
//User Log response
//SMARTLINK_MSG_APP::MsgType = 0x7FFC
typedef struct tag_stMsg_UploadUserListRsp{
unsigned __int8 DoneCode;
//char TextInfo[64]; //char TextInfo[64];
} stMsg_UploadUserListRsp; } stMsg_UploadUserListRsp;
...@@ -130,18 +52,18 @@ namespace ExampleServer{ ...@@ -130,18 +52,18 @@ namespace ExampleServer{
//SMARTLINK_MSG_APP::MsgType = 0x7FFB //SMARTLINK_MSG_APP::MsgType = 0x7FFB
typedef struct tag_stMsg_DownloadUserListRsp{ typedef struct tag_stMsg_DownloadUserListRsp{
unsigned __int8 DoneCode; quint8 DoneCode;
unsigned __int16 UserNum; quint16 UserNum;
unsigned __int32 pUserIDList[1]; quint32 pUserIDList[1];
} stMsg_DownloadUserListRsp; } stMsg_DownloadUserListRsp;
typedef struct tag_example_app_layer{ typedef struct tag_example_app_layer{
struct tag_app_layer_header{ struct tag_app_layer_header{
unsigned __int16 MsgFmtVersion; quint16 MsgFmtVersion;
unsigned __int8 AskID; quint8 AskID;
unsigned __int16 MsgType; quint16 MsgType;
} header; } header;
union union_MsgUnion union union_MsgUnion
{ {
...@@ -158,8 +80,6 @@ namespace ExampleServer{ ...@@ -158,8 +80,6 @@ namespace ExampleServer{
} EXAMPLE_MSG_APP; } EXAMPLE_MSG_APP;
#endif
#pragma pack(pop) #pragma pack(pop)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册