game2006go/server/imserver/proto/cs_proto.proto
2023-08-30 13:52:07 +08:00

487 lines
10 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";
/*
约定:
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; //服务器信息(重连时使用)
optional string account_id = 2;
}
//断线重连
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; //错误描述
}
// 请求好友信息
message CMFriendInfo
{
}
// 回复好友信息
message SMFriendInfo
{
repeated string friendships_account_ids = 1;
repeated string pending_reqs_account_ids = 2;
repeated string blacklist_account_ids = 3;
}
// 请求搜索用户
message CMSearchUser
{
optional string search_keyword = 1; //搜索文本关键字
}
// 回复搜索用户
message SMSearchUser
{
repeated MFUser users = 1;
}
// 请求搜索用户 CMSearchUserByAccountId
message CMSearchUserByAccountId
{
optional string account_id = 1; //搜索account id
}
// 回复搜索用户
message SMSearchUserByAccountId
{
optional string account_id = 1;
optional string username = 2;
}
// 请求发送添加好友请求
message CMAddFriendRequest
{
optional string target_account_id = 1; // 账号id
}
// 回复发送添加好友请求
message SMAddFriendRequest
{
optional string reason = 1;
optional string status = 2;
}
// 请求接受好友请求
message CMAcceptFriendRequest
{
optional string target_account_id = 1; // 账号id
}
// 回复接受好友请求
message SMAcceptFriendRequest
{
optional string reason = 1;
optional string status = 2;
}
// 请求拒绝好友请求
message CMRejectFriendRequest
{
optional string target_account_id = 1; // 账号id
}
// 回复拒绝好友请求
message SMRejectFriendRequest
{
optional string reason = 1;
optional string status = 2;
}
// 请求等待验证的好友请求
message CMListPendingFriendRequest
{
}
// 回复等待验证的好友请求
message SMListPendingFriendRequest
{
repeated string accountIds = 1;
}
// 请求我的好友列表
message CMListFriend
{
}
// 回复我的好友列表
message SMListFriend
{
repeated MFUser users = 1;
}
// 请求删除好友
message CMDeleteFriendShip
{
optional string target_account_id = 1; // 账号id
}
// 回复删除好友
message SMDeleteFriendShip
{
optional string reason = 1;
optional string status = 2;
}
// 请求加入黑名单
message CMAddBlacklist
{
optional string target_account_id = 1; // 账号id
}
// 回复加入黑名单
message SMAddBlacklist
{
optional string reason = 1;
optional string status = 2;
}
// 请求移除黑名单
message CMRemoveBlacklist
{
optional string target_account_id = 1; // 账号id
}
// 回复移除黑名单
message SMRemoveBlacklist
{
optional string reason = 1;
optional string status = 2;
}
message MFUser {
optional string account_id = 1;
optional string username = 2;
}
// --- 聊天 ---
// 发送聊天消息
message CMSendChatMsg
{
optional int32 chat_channel = 1; //聊天频道 1: 世界 2好友 3战队 4:小队这时target表示队伍Id 5大喇叭 6跑马灯只能收不能发
optional string targetAccountId = 2; //目标
optional int32 msg_type = 3; ////消息类型 0文本消息(json) 1自定义协议 (json) 2:纯文本(但是任会做屏蔽字替换)
optional string msg_body = 4; //消息内容
repeated string members = 5; //小队成员列表(包含自己)
}
//读取聊天消息列表并且开启聊天通知
message CMReadMsgAndOpenChatNotify
{
optional int32 curr_channel = 1; //当前频道
repeated MFPair64 last_ids = 2; //所有频道 key聊天频道 val该频道最后一次收到的消息id
}
//设置当前私聊目标
message CMSetCurrPrivateChatTarget
{
optional string target_account_id = 1; //私聊对象id, 只有当前聊频道是私聊时字段才有意义
optional int64 last_id = 2; //最后收到想消息id
}
//关闭聊天通知
message CMCloseChatNotify
{
}
//更新聊天红点信息
message SMUpdateChatRedPointNotify
{
repeated int32 has_unread_msg_channels = 1; //含有未读消息的渠道id列表不在列表里的渠道默认不含有
}
message SMChatMsgNotify
{
repeated MFChatMsg msg_list = 1; //消息列表客户端需要根据chat_channel和msg_uuid更新本地的last_ids
}
//更新红点信息
message SMUpdateRedPointNotify
{
optional int32 red_point_flags = 1; //红点信息 1<<0:好友申请 1<<1:公会申请 1<<2聊天红点
}
//更新私聊红点信息
message SMUpdatePrivateChatRedPointNotify
{
repeated string has_unread_msg_accounts = 1; //有未读消息的账号列表不在列表里的好友more不含有
}
//更新频道最后一次收到的消息id
message SMUpdateChatChannelLastId
{
repeated MFPair64 last_ids = 1; //所有频道 key聊天频道 val该频道最后一次收到的消息id
}
//聊天消息
message MFChatMsg
{
/*
消息唯一id递增序列,客户端可以用chat_channel + msg_uuid作为主键
!!!不同的频道msg_uuid可能重复
*/
optional uint64 msg_uuid = 1;
optional string sender = 2; //发送者
optional string receiver = 3; //接收者
optional int32 chat_channel = 4; //聊天频道
optional int32 msg_type = 5; //消息类型 0文本消息(json) 1自定义协议 (json) 2:纯文本(但是任会做屏蔽字替换)
optional string msg_body = 6; //消息内容(json类型里的字段!开头的会做屏蔽替换)
optional int64 send_time = 7; //消息发送时间
}
// --- 公会 ---
// 请求公会信息
message CMGuildInfo
{
}
// 回复公会信息
message SMGuildInfo
{
optional MFGuild guild = 1;
repeated MFGuild random_guilds = 2;
}
// 请求创建公会
message CMCreateGuild
{
optional string name = 1;
}
// 回复创建公会
message SMCreateGuild
{
optional int64 guild_id = 1;
optional string err_msg = 2;
}
// 请求申请加入公会
message CMApplyToGuild
{
optional int64 guild_id = 1;
}
// 回复创建公会
message SMApplyToGuild
{
optional string err_msg = 1;
}
// 请求批准申请加入公会
message CMApprove
{
optional int64 guild_id = 1;
optional string applicant_account_id = 2;
}
// 回复批准申请加入公会
message SMApprove
{
optional string err_msg = 1;
}
// 请求批准申请加入公会
message CMReject
{
optional int64 guild_id = 1;
optional string applicant_account_id = 2;
}
// 回复批准申请加入公会
message SMReject
{
optional string err_msg = 1;
}
// 请求离开公会
message CMLeaveGuild
{
optional int64 guild_id = 1;
}
// 回复离开公会
message SMLeaveGuild
{
optional string err_msg = 1;
}
// 请求开除成员
message CMDismissMember
{
optional int64 guild_id = 1;
optional string dismissAccountId = 2;
}
// 回复开除成员
message SMDismissMember
{
optional string err_msg = 1;
}
// 请求提升成员为干部
message CMPromoteMember
{
optional int64 guild_id = 1;
optional string promoteAccountId = 2;
}
// 回复提升成员为干部
message SMPromoteMember
{
optional string err_msg = 1;
}
// 请求解除成员干部身份
message CMDemoteMember
{
optional int64 guild_id = 1;
optional string demoteAccountId = 2;
}
// 回复解除成员干部身份
message SMDemoteMember
{
optional string err_msg = 1;
}
// 请求解散公会
message CMDisband
{
optional int64 guild_id = 1;
}
// 回复解散公会
message SMDisband
{
optional string err_msg = 1;
}
// 请求搜索公会
message CMSearchGuilds
{
optional string keyword = 1;
}
// 回复搜索公会
message SMSearchGuilds
{
repeated MFGuild guilds = 1;
}
message MFGuild {
optional int64 guild_id = 1;
optional string name = 2;
optional string leader_id = 3;
optional int32 members = 4;
optional int32 max_members = 5;
}