-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,481 additions
and
1,076 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.