//syntax = "proto2"; package kingsomevs; /* 约定: CM前缀:客户端发给服务器的消息(client message) SM前缀:服务器发给客户的的消息(server message) MF前缀:消息的内嵌字段,只能作为其他消息的内嵌字段不能send(message field) custom_data: 自定义用户数据,透传数据 _e后缀:枚举类型 网络包格式:msghead + msgbody msghead: packagelen + msgid + magiccode = 2 + 2 + 4 = 8字节 msgbody: protobuf数据 msghead说明 packagelen(unsigned short): 双字节网络包长度, msgid(unsigned short): 双字节消息id magiccode(unsigned int): 4字节魔数,并且为固定常数0xAABBCCAA,占位符客户端不需什么处理 */ //操作结果公用类型 message MFOptResult { optional int32 error_code = 1; //错误代码 optional string error_msg = 2; //错误描述 optional string debug_msg = 3; //调试用 } //房间用户信息 message MFRoomUserInfo { optional string account_id = 1; //用户id optional string user_profile = 2; //玩家简介,可以填写昵称、段位等信息 optional int32 user_idx = 3; //用户索引,按用户加入房间的顺序递增 } //房间机器人信息 message MFRoomRobotInfo { optional string robot_uniid = 1; //机器人唯一id optional string robot_name = 2; //机器人名字 optional string avatar_url = 3; //头像地址,空的话本地随机头像 } //房间事件信息 message MFRoomEventInfo { optional string custom_data = 1; //透传字段 optional string src_account_id = 2; //事件发起者id } //房间信息 message MFRoomInfo { optional string room_id = 1; //房间 optional string owner_id = 2; //房间创建者的用户ID optional string room_property = 3; // 房间属性 optional int32 _timestamp = 4; //时间戳毫秒(相对于房间创建时间时) optional int32 create_time = 5; //创建时间 optional int32 max_player = 6; //最大玩家数 optional int32 allow_merge = 7 [default = 0]; //允许合并 0:否 1:是 repeated MFRoomRobotInfo robot_list = 8; //机器人列表 size() == max_player optional int32 started = 9; //0:游戏未开始 1:游戏已经开始 optional int32 reset_count = 10; //房间重置次数 创建时为0之后每重置一次++ optional int32 join_over = 11; //0:允许加入 1:不允许加入 optional int32 auto_exit_room = 12; //连接断开后自动退房间 0:不退(还可以重连) 1:自动退(无法重连只能再走一次加房间流程) } //创建房间信息 message MFCreateRoomInfo { optional string room_name = 1; //房间名 optional int32 max_player = 2; //最大玩家数 optional int32 allow_merge = 3 [default = 0]; //允许合并 0:否 1:是 optional int32 auto_exit_room = 4; //连接断开后自动退房间 0:不退(还可以重连) 1:自动退(无法重连只能再走一次加房间流程) } //帧事件项 message MFFrameItem { optional string src_account_id = 1; //用户id optional string custom_data = 2; //透传数据 optional double timestamp = 3; //时间戳(单位毫秒) } //帧事件 message MFFrameEventInfo { optional int32 frame_index = 1; //帧序号 repeated MFFrameItem frame_items = 2; //同步帧内的数据包数组 optional int32 frame_wait_count = 3; //同步帧内的数据包数组数量 } //-------------------------mfxxx end--------------------------------------- //登录 message CMLogin { optional string account_id = 1; //用户id optional string session_id = 2; //session_id optional string game_id = 3; //game_id optional string device_id = 4; //device_id } message SMLogin { optional MFOptResult result = 1; //error_code 0: 成功 -1: 失败 optional string room_id = 2; //房间id } //心跳 message CMPing { } message SMPing { } //创建房间 message CMCreateRoom { optional MFCreateRoomInfo create_room_info = 1; //创建房间信息 optional string user_profile = 2; //玩家简介,可以填写昵称、段位等信息 } message SMCreateRoom { optional MFOptResult result = 1; //error_code 0: 成功 -1: 失败 -2: 未登录 -3: 已在房间 -4:正在匹配 optional string room_id = 2; //房间id optional int32 create_time = 5; //创建时间 optional MFRoomInfo room_info = 6; //房间信息 } //加入随机房间 message CMJoinRandomRoom { optional int32 max_player = 1; //最大玩家数 optional string user_profile = 2; //玩家简介,可以填写昵称、段位等信息 } message SMJoinRandomRoom { optional MFOptResult result = 1; //error_code 0: 成功 -3: 已在房间 -4:正在匹配 optional MFRoomInfo room_info = 2; //房间信息 repeated MFRoomUserInfo room_user_info_list = 3; //房间用户信息列表 } //加入指定房间 message CMJoinRoom { optional string room_id = 1; //房间id optional string user_profile = 2; //玩家简介,可以填写昵称、段位等信息 } message SMJoinRoom { optional MFOptResult result = 1; //error_code 0: 成功 -1: 房间id不存在 -2: 房间已满 -3: 已在房间 -4:正在匹配 -5:无法加入 optional MFRoomInfo room_info = 2; //房间信息 repeated MFRoomUserInfo room_user_info_list = 3; //房间用户信息列表 } //加入房间通知 message SMRoomPeerJoinNotify { optional MFRoomUserInfo room_user_info = 1; //房间用户信息 } //踢人 message CMKickPlayer { optional string account_id = 1; //用户id optional string custom_data = 2; //透传数据 } message SMKickPlayer { optional MFOptResult result = 1; //error_code 0: 成功 -1: 失败 optional string account_id = 2; //用户id optional string custom_data = 3; //透传数据 } //踢人notify message SMRoomKickPlayerNotify { optional string account_id = 1; //用户id optional string custom_data = 2; //透传数据 optional string owner_id = 3; //房主 } //加入房间结束 message CMJoinOver { optional string custom_data = 1; //自定义内容 } message SMJoinOver { optional MFOptResult result = 1; // optional string custom_data = 2; //自定义内容 } //加入房间结束notify message SMJoinOverNotify { optional string custom_data = 1; //透传数据 } //加入房间开启 message CMJoinOpen { optional string custom_data = 1; //自定义内容 } message SMJoinOpen { optional MFOptResult result = 1; // optional string custom_data = 2; //自定义内容 } //加入房间开启notify message SMJoinOpenNotify { optional string custom_data = 1; //自定义内容 } //游戏开始 message CMGameStart { optional string custom_data = 1; //自定义内容 } message SMGameStart { optional MFOptResult result = 1; // optional string custom_data = 2; //自定义内容 } //发送房间数据 message CMSendRoomEvent { optional string custom_data = 1; //消息内容 } message SMSendRoomEvent { optional MFOptResult result = 1; // optional string event_id = 2; //事件唯一id optional string custom_data = 3; //消息内容 optional int32 _timestamp = 4; //时间戳毫秒(相对于房间创建时间时) } //房间数据同步消息 message SMRoomEventNotify { optional string src_account_id = 1; //事件发起者id optional string event_id = 2; //事件唯一id optional string custom_data = 3; //消息内容 optional int32 _timestamp = 4; //时间戳毫秒(相对于房间创建时间时) } //发送离开房间 message CMLeaveRoom { optional string custom_data = 1; //自定义内容 } message SMLeaveRoom { optional MFOptResult result = 1; //error_code 0: 成功 -1: 未在房间中 optional string room_id = 2; //房间id optional string account_id = 3; //用户id optional string custom_data = 4; //消息内容 } //设置房间参数 message CMSetRoomParam { optional int32 allow_merge = 1 [default = 0]; //允许合并 0:否 1:是 } message SMSetRoomParam { optional MFOptResult result = 1; //error_code 0: 成功 其他失败 } //重置房间状态 当前重置的信息:started 帧事件相关所有字段 //注意帧率会改为0客户端需要再次设置帧率会开启新的帧事件 message CMResetRoom { optional int32 join_over = 1; //重置后 0:允许加入 1:不允许加入 } message SMResetRoom { optional MFOptResult result = 1; //error_code 0: 成功 其他失败 } //强退房间(客户端matchvs sdk层实现,应用层不要主动调用该方法) //客户端记录最后一次进入的房间,当玩家要进入或者创建新的房间时候应主动发CMForceExitRoom消息退上一个房间 message CMForceExitRoom { optional string room_id = 1; //房间id } //其他人离开房间通知 message SMRoomPeerLeaveNotify { optional string room_id = 1; //房间id optional MFRoomUserInfo room_user_info = 2; //房间用户信息 optional int32 reason = 3; //0:主动退出 1:断线自动退房(auto_exit_room) 2:CMForceExitRoom } //设置同步帧率 message CMSetFrameSync { optional int32 frame_rate = 1; //每秒钟同步的帧数 } message SMSetFrameSync { optional MFOptResult result = 1; //error_code 0: 成功 -1: frame_rate大于30 optional int32 frame_rate = 2; //每秒钟同步的帧数 } //发送帧事件 message CMSendFrameEvent { optional string custom_data = 1; //透传 } message SMSendFrameEvent { optional MFOptResult result = 1; //操作结果 } //断线重连 message CMReConnect { optional string room_id = 1; //房间 optional string account_id = 2; //用户id optional string session_id = 3; //session_id } message SMReConnect { optional MFOptResult result = 1; //error_code 0: 成功 -1:session已失效 -2:房间不存在 -3 optional MFRoomInfo room_info = 2; //房间信息 repeated MFRoomUserInfo room_user_info_list = 3; //房间用户信息列表 } //房间内玩家收到帧同步的回调 //注意 需要在客户端保持帧同步的状态,服务器不会保存 message SMFrameEventUpdateNotify { optional MFFrameEventInfo frame_info = 1; //帧信息 } //房间解散通知 message SMRoomDisbandNotify { optional string room_id = 1; //房间id } //房间合并通知 source 并入 target message SMRoomMergeNotify { optional string source_room_id = 1; //源房间id optional MFRoomInfo target_room_info = 2; //房间信息 repeated MFRoomUserInfo target_room_user_info_list = 3; //房间用户信息列表 } //房间重置通知 message SMRoomResetNotify { optional MFRoomInfo room_info = 1; //房间信息 repeated MFRoomUserInfo room_user_info_list = 2; //房间用户信息列表 } //网络状态 message SMNetWorkStateNotify { optional string room_id = 1; //房间id optional string account_id = 2; //账号 optional int32 state = 3; //网络断开状态 1-网络异常,正在重连 2-重连成功 3-重连失败,退出房间 optional string owner = 4; //房主id }