aozhiwei 6736982cc2 1
2024-10-15 17:20:27 +08:00

402 lines
9.3 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
optional int32 mode_id = 2; //地图mapMode表.id
}
//加入队伍参数
message MFJoinTeamParams
{
optional string team_uuid = 1; //队伍唯一id
}
//英雄信息
message MFHero
{
optional int32 hero_id = 1; //英雄id
optional int32 quality = 2; //英雄品阶
optional int32 current_times = 3; //当前打金次数
optional int32 total_times = 4; //总打金次数
optional int32 skin_id = 5; //皮肤id
}
//加入房间消息
message MFJoinMsg
{
optional string team_uuid = 1; //用于发CMMove
optional string payload = 2; //透传数据
}
//带入战斗的道具
message MFBattleItem
{
optional int32 item_id = 1; //道具id
optional int32 item_num = 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; //是否已准备
optional int32 id = 10; //编号
optional int32 wealth = 11; //财富值
optional int64 total_lucky = 12; //英雄的 lucky 字段的总和
optional int32 valid_lefttime = 13; //最大有效时间
optional int32 admission_item_num = 14; //门票数
optional int32 battling = 15; //是否战斗中
optional int32 circuit_score = 16; //循回赛积分
optional int32 vip_lv = 17; //vip等级
optional int64 vip_exp = 18; //vip经验
optional int32 has_vip_lucky = 19; //是否有vip幸运值加成
repeated MFBattleItem battle_items = 20; //带入战斗的道具
optional int32 has_lucky_symbol = 21; //是否已使用幸运符
}
//队伍信息
message MFTeam
{
optional string team_uuid = 1; //队伍唯一id
repeated MFTeamMember members = 2; //成员信息
optional int32 map_id = 4; //地图id
optional int32 mode_id = 5; //地图mapMode表.id
}
//最后一次战斗信息
message MFLastBattleInfo
{
optional int32 map_id = 1; //地图id
optional int32 mode_id = 2; //地图mapMode表.id
optional int32 start_time = 3; //开始时间
optional int32 interval_time = 6; //间隔时间(单位秒,<=0无间隔
}
//登录
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
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//踢人
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
{
optional int32 is_ready = 1; //是否已准备
}
message SMSetReady
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//设置召唤师技能
message CMSetSpecSkill
{
optional int32 skill_id = 1; //技能id
}
message SMSetSpecSkill
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//选择英雄
message CMChooseHero
{
optional string hero_uniid = 1; //英雄唯一id
}
message SMChooseHero
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//选择地图
message CMChooseMap
{
optional int32 map_id = 1; //地图id
optional int32 mode_id = 2; //地图mapMode表.id
}
message SMChooseMap
{
optional int32 errcode = 1; //错误码 0成功
optional string errmsg = 2; //错误描述
}
//刷新用户信息一般是短连接修改了用户相关数据时调用
message CMRefreshUser
{
}
message SMRefreshUser
{
}
//选择带入战斗的道具
message CMChooseBattleItem
{
optional int32 item_id = 1; //道具id
}
message SMChooseBattleItem
{
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
{
optional MFTeam team_info = 1; //队伍信息
}
//队伍状态通知(会发多次!!!)
message SMTeamStateNotify
{
optional int32 state = 1; //0已取消 1已开始 2正在匹配(moba模式)
optional MFJoinMsg join_msg = 2; //进入房间传的字段(只有一开始才生效)
optional string next_team_uuid = 3; //下一次队伍唯一id(当state=1是才有效)
repeated MFTeam team_list = 4; //队伍列表
}
//队伍解散通知
message SMTeamDisbandNotify
{
}
//队伍被踢通知
message SMTeamKickoutNotify
{
optional string account_id = 1; //账号id
}
//最后一次战斗信息
message SMPushLastBattleInfo
{
repeated MFLastBattleInfo battle_list = 1; //战斗信息
}