game2006go/server/imserver/proto/cs_proto.proto
2023-08-09 15:25:58 +08:00

118 lines
2.6 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.

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说明
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 CMLogin
{
optional int32 server_id = 1; //保留
optional string team_uuid = 2; //保留
optional string account_id = 3; //账号id
optional int32 proto_version = 5; //协议版本号Constant_e.ProtoVersion
optional string session_id = 20; //账号id
}
//登录回复
message SMLogin
{
optional string server_info = 1; //服务器信息(重连时使用)
}
//断线重连
message CMReconnect
{
optional int32 server_id = 1; //保留
optional string team_uuid = 2; //保留
optional string account_id = 3; //账号id
optional string session_id = 4; //session_id
optional string room_uuid = 5; //房间唯一id
optional string server_info = 6; //服务器信息
}
//断线重连回复
message SMReconnect
{
optional int32 errcode = 1; //错误码 0成功 1:重连失败
optional string errmsg = 2; //错误描述
}