Skip to content

Commit

Permalink
update protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
zsummer committed Feb 7, 2015
1 parent 86e5762 commit b008568
Show file tree
Hide file tree
Showing 30 changed files with 1,481 additions and 1,076 deletions.
405 changes: 186 additions & 219 deletions depends_linux/include/proto4z/proto4z.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions depends_linux/include/zsummerX/frame/FrameHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ struct FrameStreamTraits
};


typedef zsummer::proto4z::ReadStream<FrameStreamTraits> ReadStreamPack;
typedef zsummer::proto4z::WriteStream<FrameStreamTraits> WriteStreamPack;
typedef zsummer::proto4z::ReadStream ReadStreamPack;
typedef zsummer::proto4z::WriteStream WriteStreamPack;


//!register message with original net pack, if return false other register will not receive this message.
Expand Down
Binary file modified depends_linux/lib/liblog4z.a
Binary file not shown.
Binary file modified depends_linux/lib/liblog4z_d.a
Binary file not shown.
Binary file modified depends_linux/lib/libzsummerX.a
Binary file not shown.
Binary file modified depends_linux/lib/libzsummerX_d.a
Binary file not shown.
405 changes: 186 additions & 219 deletions depends_win/include/proto4z/proto4z.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions depends_win/include/zsummerX/frame/FrameHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ struct FrameStreamTraits
};


typedef zsummer::proto4z::ReadStream<FrameStreamTraits> ReadStreamPack;
typedef zsummer::proto4z::WriteStream<FrameStreamTraits> WriteStreamPack;
typedef zsummer::proto4z::ReadStream ReadStreamPack;
typedef zsummer::proto4z::WriteStream WriteStreamPack;


//!register message with original net pack, if return false other register will not receive this message.
Expand Down
Binary file modified depends_win/lib/log4z_win64.lib
Binary file not shown.
Binary file modified depends_win/lib/log4z_win64.pdb
Binary file not shown.
Binary file modified depends_win/lib/log4z_win64d.idb
Binary file not shown.
Binary file modified depends_win/lib/log4z_win64d.lib
Binary file not shown.
Binary file modified depends_win/lib/log4z_win64d.pdb
Binary file not shown.
Binary file modified depends_win/lib/zsummerX_win64.lib
Binary file not shown.
Binary file modified depends_win/lib/zsummerX_win64d.idb
Binary file not shown.
Binary file modified depends_win/lib/zsummerX_win64d.lib
Binary file not shown.
Binary file modified depends_win/lib/zsummerx_win64.pdb
Binary file not shown.
Binary file modified depends_win/lib/zsummerx_win64d.pdb
Binary file not shown.
171 changes: 102 additions & 69 deletions protocol/C++/ProtoCommon.h
Original file line number Diff line number Diff line change
@@ -1,70 +1,103 @@

#ifndef _PROTOCOMMON_H_
#define _PROTOCOMMON_H_

const unsigned short BEC_SUCCESS = 0; //成功
const unsigned short BEC_UNKOWN_ERROR = 1; //未知错误
const unsigned short BEC_INNER_ERROR = 2; //内部错误
const unsigned short BEC_DB_ERROR = 3; //数据库错误
const unsigned short BEC_PARAM_DENIED = 4; //非法参数
const unsigned short BEC_PERMISSION_DENIED = 5; //权限非法
const unsigned short BEC_SYSTEM_ERROR = 6; //系统错误
const unsigned short BEC_INVALIDE_USERID = 50; //用户ID无效
const unsigned short BEC_AUTH_USER_NOT_EXIST = 60; //认证错误:用户不存在
const unsigned short BEC_AUTH_PASSWD_INCORRECT = 61; //认证错误:密码错误
const unsigned short BEC_AUTH_ING = 62; //认证错误:正在认证中...
const unsigned short BEC_AUTH_AREADY_AUTH = 63; //认证错误:已认证
const unsigned short BEC_AUTH_LIMITE_COUNT = 64; //认证错误:认证次数超过限制

struct UserInfo //用户信息
{
unsigned long long uid;
std::string nickName; //用户昵称
unsigned int iconID; //头像
unsigned int level; //等级
unsigned int diamond; //当前剩余的充值钻石
unsigned int hisotryDiamond; //历史充值钻石总额
unsigned int giftDiamond; //当前剩余的赠送钻石
unsigned int joinTime; //加入时间
UserInfo()
{
uid = 0;
iconID = 0;
level = 0;
diamond = 0;
hisotryDiamond = 0;
giftDiamond = 0;
joinTime = 0;
}
};
template<class T>
T & operator << (T & t, const UserInfo & data)
{
t << data.uid;
t << data.nickName;
t << data.iconID;
t << data.level;
t << data.diamond;
t << data.hisotryDiamond;
t << data.giftDiamond;
t << data.joinTime;
return t;
}
template<class T>
T & operator >> (T & t, UserInfo & data)
{
t >> data.uid;
t >> data.nickName;
t >> data.iconID;
t >> data.level;
t >> data.diamond;
t >> data.hisotryDiamond;
t >> data.giftDiamond;
t >> data.joinTime;
return t;
}

typedef std::vector<UserInfo> UserInfoVct;

#endif

#ifndef _PROTOCOMMON_H_
#define _PROTOCOMMON_H_

const unsigned short BEC_SUCCESS = 0; //成功
const unsigned short BEC_UNKOWN_ERROR = 1; //未知错误
const unsigned short BEC_INNER_ERROR = 2; //内部错误
const unsigned short BEC_DB_ERROR = 3; //数据库错误
const unsigned short BEC_PARAM_DENIED = 4; //非法参数
const unsigned short BEC_PERMISSION_DENIED = 5; //权限非法
const unsigned short BEC_SYSTEM_ERROR = 6; //系统错误
const unsigned short BEC_INVALIDE_USERID = 50; //用户ID无效
const unsigned short BEC_AUTH_USER_NOT_EXIST = 60; //认证错误:用户不存在
const unsigned short BEC_AUTH_PASSWD_INCORRECT = 61; //认证错误:密码错误
const unsigned short BEC_AUTH_ING = 62; //认证错误:正在认证中...
const unsigned short BEC_AUTH_AREADY_AUTH = 63; //认证错误:已认证
const unsigned short BEC_AUTH_LIMITE_COUNT = 64; //认证错误:认证次数超过限制

struct UserInfo //用户信息
{
unsigned long long uid;
std::string nickName; //用户昵称
unsigned int iconID; //头像
unsigned int level; //等级
unsigned int diamond; //当前剩余的充值钻石
unsigned int hisotryDiamond; //历史充值钻石总额
unsigned int giftDiamond; //当前剩余的赠送钻石
unsigned int joinTime; //加入时间
UserInfo()
{
uid = 0;
iconID = 0;
level = 0;
diamond = 0;
hisotryDiamond = 0;
giftDiamond = 0;
joinTime = 0;
}
};
inline zsummer::proto4z::WriteStream & operator << (zsummer::proto4z::WriteStream & ws, const UserInfo & data)
{
unsigned long long tag = 255ULL;
ws << (zsummer::proto4z::Integer)0;
zsummer::proto4z::Integer offset = ws.getStreamLen();
ws << tag;
ws << data.uid;
ws << data.nickName;
ws << data.iconID;
ws << data.level;
ws << data.diamond;
ws << data.hisotryDiamond;
ws << data.giftDiamond;
ws << data.joinTime;
ws.fixOriginalData(offset - 4, ws.getStreamLen() - offset);
return ws;
}
inline zsummer::proto4z::ReadStream & operator >> (zsummer::proto4z::ReadStream & rs, UserInfo & data)
{
zsummer::proto4z::Integer sttLen = 0;
rs >> sttLen;
zsummer::proto4z::Integer cursor = rs.getStreamUnreadLen();
unsigned long long tag = 0;
rs >> tag;
if ( (1ULL << 0) & tag)
{
rs >> data.uid;
}
if ( (1ULL << 1) & tag)
{
rs >> data.nickName;
}
if ( (1ULL << 2) & tag)
{
rs >> data.iconID;
}
if ( (1ULL << 3) & tag)
{
rs >> data.level;
}
if ( (1ULL << 4) & tag)
{
rs >> data.diamond;
}
if ( (1ULL << 5) & tag)
{
rs >> data.hisotryDiamond;
}
if ( (1ULL << 6) & tag)
{
rs >> data.giftDiamond;
}
if ( (1ULL << 7) & tag)
{
rs >> data.joinTime;
}
cursor = cursor - rs.getStreamUnreadLen();
rs.skipOriginalData(sttLen - cursor);
return rs;
}

typedef std::vector<UserInfo> UserInfoVct;

#endif
Loading

0 comments on commit b008568

Please sign in to comment.