aozhiwei 320df05ece 1
2024-03-11 18:02:17 +08:00

267 lines
5.8 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto2";
package cs;
option go_package = ".;cs";
//用来指定出生的lua模块名, lua_package不支持!!!
option java_package = "match_proto_pb";
/*
约定:
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说明
packagelenunsigned 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 MFCreateTeamParams
{
optional int32 map_id = 1; //地图id
}
//加入队伍参数
message MFJoinTeamParams
{
optional string team_uuid = 1; //队伍唯一id
}
//英雄信息
message MFHero
{
optional int32 hero_id = 1; //英雄id
optional int32 quality = 2; //英雄品阶
}
//队伍成员
message MFTeamMember
{
optional string account_id = 1; //账号id
optional string name = 2; //昵称
optional int32 is_leader = 3; //是否队长
optional int32 spec_skill = 4; //召唤师技能id
optional MFHero hero = 5; //英雄信息
optional int32 state = 6; //状态 1: free 2:battling
optional int32 online = 7; //是否在线
optional int32 permission = 8; //是否有邀请权限
optional int32 is_ready = 9; //是否已准备
}
//登录
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
//以下二者只能2选一赋值
optional MFCreateTeamParams create_team_param = 30;
optional MFJoinTeamParams join_team_param = 31;
}
//登录回复
message SMLogin
{
optional int32 errcode = 7; //错误码 0成功 1:重连失败
optional string errmsg = 10; //错误描述
optional string server_info = 9; //服务器信息(重连时使用)
optional string team_uuid = 20; //队伍唯一id
}
//断线重连
message CMReconnect
{
optional int32 reserved0 = 1; //保留
optional string team_uuid = 2; //队伍唯一id
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 CMLeaveTeam
{
}
message SMLeaveTeam
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//解散队伍
message CMDisbandTeam
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
message SMDisbandTeam
{
}
//踢人
message CMKickOut
{
optional string target_id = 1; //目标account_id
}
message SMKickOut
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//转移队长
message CMHandoverLeader
{
optional string target_id = 1; //目标account_id
}
message SMHandoverLeader
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//开始游戏
message CMStartGame
{
}
message SMStartGame
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//取消开始游戏
message CMCancel
{
}
message SMCancel
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//设置状态为已准备
message CMSetReady
{
}
message SMSetReady
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//授予邀请队友权限
message CMGrantInvitePermission
{
optional string target_id = 1; //目标account_id
}
message SMGrantInvitePermission
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//队伍信息更新通知
message SMTeamUpdateNotify
{
repeated MFTeamMember members = 1; //成员信息
}