344 lines
7.9 KiB
Protocol Buffer
344 lines
7.9 KiB
Protocol Buffer
syntax = "proto2";
|
||
package cs;
|
||
option go_package = ".;cs";
|
||
|
||
/*
|
||
约定:
|
||
CM前缀:客户端发给服务器的消息(client message)
|
||
SM前缀:服务器发给客户的的消息(server message)
|
||
MF前缀:消息的内嵌字段,只能作为其他消息的内嵌字段不能send(message field)
|
||
_e后缀:枚举类型
|
||
_uniid后缀:唯一id
|
||
union_前缀:联合体
|
||
_前缀:该字段仅服务器使用客户端无需处理
|
||
|
||
网络包格式:msghead + msgbody
|
||
msghead: packagelen + msgid + seqid + magiccode + reserved = 2 + 2 + 4 + 2 + 2 = 12字节
|
||
msgbody: protobuf数据
|
||
msghead说明
|
||
packagelen(unsigned short): 双字节网络包长度,
|
||
msgid(unsigned short): 双字节消息id
|
||
seqid(unsigned int): 4字节序号id
|
||
magiccode(unsigned short): 2字节魔数,并且为固定常数KS,占位符客户端不需什么处理
|
||
reserved(unsigned short): 保留
|
||
|
||
十六进制位运算数据表示法
|
||
0x01 == 1<<0
|
||
0x02 == 1<<1
|
||
0x04 == 1<<2
|
||
*/
|
||
|
||
//常量
|
||
enum Constant_e
|
||
{
|
||
ProtoVersion = 2023051601; //系统版本
|
||
}
|
||
|
||
//心跳
|
||
message CMPing
|
||
{
|
||
}
|
||
message SMPing
|
||
{
|
||
optional int32 param1 = 1;
|
||
optional int32 source = 2 [default = 0]; //0:tcp 1:udp
|
||
}
|
||
|
||
//rpc调用错误
|
||
message SMRpcError
|
||
{
|
||
optional int32 error_code = 1;
|
||
optional string error_msg = 2;
|
||
optional string debug_msg = 3;
|
||
optional string file = 4;
|
||
optional int32 lineno = 5;
|
||
optional int32 error_param = 6;
|
||
}
|
||
|
||
//int32键值对
|
||
message MFPair
|
||
{
|
||
optional int32 key = 1; //key
|
||
optional int32 value = 2; //val
|
||
}
|
||
|
||
//int64键值对
|
||
message MFPair64
|
||
{
|
||
optional int64 key = 1; //key
|
||
optional int64 value = 2; //val
|
||
}
|
||
|
||
//int32元组
|
||
message MFTuple
|
||
{
|
||
repeated int32 values = 1; //values
|
||
}
|
||
|
||
//string元组
|
||
message MFTupleString
|
||
{
|
||
repeated string values = 1; //values
|
||
}
|
||
|
||
//分页信息
|
||
message MFPagination
|
||
{
|
||
optional int32 total = 1; //总记录数
|
||
optional int32 count = 2; //当前页查到的记录数
|
||
optional int32 current_page = 3; //当前第几页
|
||
optional int32 total_page = 4; //总页数
|
||
}
|
||
|
||
//房间信息(房间列表)
|
||
message MFRoom
|
||
{
|
||
optional string room_id = 1; //房间号
|
||
optional int32 map_id = 2; //地图id
|
||
optional int32 zone_id = 3; //区id
|
||
optional int32 node_id = 4; //节点id
|
||
optional int32 has_passwd = 5; //是否有密码
|
||
optional int32 team_num = 6; //队伍数
|
||
optional int32 player_num = 7; //玩家数
|
||
optional int32 team_max_num = 8; //最大队伍数
|
||
optional int32 player_max_num = 9; //最大玩家数
|
||
|
||
optional MFMember owner = 20; //房主
|
||
}
|
||
|
||
//队伍成员信息
|
||
message MFMember
|
||
{
|
||
optional string account_id = 1; //账号id
|
||
optional string name = 2; //
|
||
optional string avatar_url = 3; //头像
|
||
optional int32 hero_id = 4; //英雄id
|
||
optional int32 state = 9; //0:准备 1:已准备
|
||
optional int32 ping = 20; //ping值(单位毫秒)
|
||
}
|
||
|
||
//队伍信息
|
||
message MFTeam
|
||
{
|
||
optional int32 team_id = 1; //队伍id
|
||
optional string team_uuid = 2; //队伍唯一id
|
||
repeated MFMember members = 3; //成员列表
|
||
}
|
||
|
||
//自己所在房间信息
|
||
message MFCurrentRoom
|
||
{
|
||
optional string room_id = 1; //房间号
|
||
optional int32 map_id = 2; //地图id
|
||
optional int32 zone_id = 3; //区id
|
||
optional int32 has_passwd = 4; //是否有密码
|
||
optional int32 team_num = 5; //队伍数
|
||
optional int32 player_num = 6; //玩家数
|
||
optional int32 team_max_num = 7; //最大队伍数
|
||
optional int32 player_max_num = 8; //最大玩家数
|
||
|
||
optional MFMember owner = 20; //房主
|
||
|
||
repeated MFTeam team_list = 30; //队伍列表
|
||
}
|
||
|
||
//登录
|
||
message CMLogin
|
||
{
|
||
optional int32 reserverd0 = 1; //保留
|
||
optional string reserved1 = 2; //保留
|
||
optional string account_id = 3; //账号id
|
||
optional int32 proto_version = 5; //协议版本号Constant_e.ProtoVersion
|
||
optional string session_id = 20; //账号id
|
||
optional int32 zone_id = 21; //国家Id
|
||
optional int32 node_id = 22; //节点id
|
||
optional int32 ping = 23; //节点id
|
||
}
|
||
|
||
//登录回复
|
||
message SMLogin
|
||
{
|
||
optional int32 errcode = 7; //错误码 0:成功 1:重连失败
|
||
optional string errmsg = 10; //错误描述
|
||
optional string server_info = 9; //服务器信息(重连时使用)
|
||
}
|
||
|
||
//断线重连
|
||
message CMReconnect
|
||
{
|
||
optional int32 reserved0 = 1; //保留
|
||
optional string reserved1 = 2; //保留
|
||
optional string account_id = 3; //账号id
|
||
optional string session_id = 4; //session_id
|
||
optional string reserverd2 = 5; //保留
|
||
optional string server_info = 6; //服务器信息
|
||
}
|
||
|
||
//断线重连回复
|
||
message SMReconnect
|
||
{
|
||
optional int32 errcode = 1; //错误码 0:成功 1:重连失败
|
||
optional string errmsg = 2; //错误描述
|
||
}
|
||
|
||
//创建房间
|
||
message CMCreateRoom
|
||
{
|
||
optional int32 map_id = 1; //地图id
|
||
optional int32 zone_id = 2; //区id
|
||
optional int32 node_id = 3; //节点id
|
||
optional string passwd = 4; //密码,空:无密码
|
||
optional string team_uuid = 5; //队伍唯一id
|
||
}
|
||
|
||
message SMCreateRoom
|
||
{
|
||
optional int32 errcode = 1; //错误码 0:成功 1:重连失败
|
||
optional string errmsg = 2; //错误描述
|
||
optional string room_id = 3; //房间号
|
||
}
|
||
|
||
//获取房间列表
|
||
message CMSearchRoom
|
||
{
|
||
optional int64 since_id = 1; //为0时表示从第一条数据开始
|
||
optional string room_id = 2; //房间id
|
||
}
|
||
|
||
message SMSearchRoom
|
||
{
|
||
optional int64 since_id = 1; //客户端需缓存
|
||
repeated MFRoom rows = 2; //数据
|
||
}
|
||
|
||
//加入房间
|
||
message CMJoinRoom
|
||
{
|
||
optional int32 map_id = 1; //地图id
|
||
optional int32 zone_id = 2; //区id
|
||
optional int32 node_id = 3; //节点id
|
||
optional string passwd = 4; //密码,空:无密码
|
||
optional string team_uuid = 5; //队伍唯一id
|
||
optional string room_id = 10; //房间号
|
||
}
|
||
|
||
message SMJoinRoom
|
||
{
|
||
optional int32 errcode = 1; //错误码 0:成功 1:重连失败
|
||
optional string errmsg = 2; //错误描述
|
||
}
|
||
|
||
//解散房间
|
||
message CMDisbandRoom
|
||
{
|
||
optional string room_id = 1; //房间号
|
||
}
|
||
|
||
message SMDisbandRoom
|
||
{
|
||
optional int32 errcode = 1; //错误码 0:成功 1:权限不足
|
||
optional string errmsg = 2; //错误描述
|
||
}
|
||
|
||
//退出房间
|
||
message CMLeaveRoom
|
||
{
|
||
optional string room_id = 1; //房间号
|
||
}
|
||
|
||
message SMLeaveRoom
|
||
{
|
||
|
||
}
|
||
|
||
//修改房间
|
||
message CMModifyRoom
|
||
{
|
||
optional int32 map_id = 1; //地图
|
||
optional string passwd = 2; //密码
|
||
}
|
||
|
||
message SMModifyRoom
|
||
{
|
||
}
|
||
|
||
//开始游戏
|
||
message CMStartGame
|
||
{
|
||
}
|
||
|
||
message SMStartGame
|
||
{
|
||
optional int32 errcode = 1; //错误码 0:成功 1:重连失败
|
||
optional string errmsg = 2; //错误描述
|
||
}
|
||
|
||
//准备
|
||
message CMSetPrepare
|
||
{
|
||
}
|
||
|
||
//踢队伍(房主才有权限)
|
||
message CMKickoutTeam
|
||
{
|
||
optional string team_uuid = 1; //队伍唯一id
|
||
}
|
||
|
||
//踢成员
|
||
message CMKickoutMember
|
||
{
|
||
optional string target_id = 1; //目标account_id
|
||
}
|
||
|
||
//关闭通知
|
||
message CMCloseNotify
|
||
{
|
||
optional int32 param = 1; //1:关闭SMRoomGameStartNotify
|
||
}
|
||
|
||
//上报ping值
|
||
message CMReportPingValue
|
||
{
|
||
optional int32 ping = 1;
|
||
}
|
||
|
||
//房间成员信息变更通知
|
||
message SMRoomMemberChangeNotify
|
||
{
|
||
optional MFMember member = 1; //成员信息
|
||
}
|
||
|
||
//房间踢人通知
|
||
message SMRoomKickoutNotify
|
||
{
|
||
repeated string account_ids = 1; //成员account_id列表
|
||
}
|
||
|
||
//房间玩家离开通知
|
||
message SMRoomLeaveNotify
|
||
{
|
||
repeated string account_ids = 1; //成员account_id列表
|
||
}
|
||
|
||
//房间解散通知
|
||
message SMRoomDisbandNotify
|
||
{
|
||
optional string room_id = 1; //房间id
|
||
optional int32 reason = 2; //解散原因 0:系统解散(倒计时超时后队伍数<2) 1:房主解散
|
||
}
|
||
|
||
//房间信息变更通知
|
||
message SMRoomChangeNotify
|
||
{
|
||
optional MFRoom room = 1; //房间信息
|
||
}
|
||
|
||
//房间游戏开始通知,这个消息游戏开始后10秒内每秒通知,客户端需要做重复消息处理
|
||
message SMRoomGameStartNotify
|
||
{
|
||
optional int32 zone_id = 1; //区id
|
||
optional int32 node_id = 2; //节点id
|
||
optional string team_uuid = 3; //CMJoin战斗服时用
|
||
optional string custom_room_payload = 4; //自定义房间透传数据
|
||
}
|