-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogic.proto
126 lines (105 loc) · 2.32 KB
/
logic.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
syntax = "proto3";
package imfun.logic;
option go_package = "github.com/zhixunjie/im-fun/api/pb;pb";
import "protocol.proto";
service Logic {
// 建立TCP连接,并且auth后,保存映射关系
rpc Connect(ConnectReq) returns (ConnectReply);
// 断开TCP连接,删除映射关系
rpc Disconnect(DisconnectReq) returns (DisconnectReply);
// Heartbeat
rpc Heartbeat(HeartbeatReq) returns (HeartbeatReply);
// RenewOnline
rpc RenewOnline(OnlineReq) returns (OnlineReply);
// Receive
rpc Receive(ReceiveReq) returns (ReceiveReply);
// ServerList
rpc Nodes(NodesReq) returns (NodesReply);
}
message KafkaSendMsg {
enum Type {
ToUsers = 0;
ToRoom = 1;
ToAll = 2;
}
Type type = 1;
int32 subId = 2;
int32 speed = 3;
string serverId = 4;
string roomId = 5;
repeated string tcpSessionIds = 6;
bytes msg = 7;
}
message ConnectCommon {
string serverId = 1;
uint64 userId = 2;
string tcpSessionId = 3;
}
// 建立TCP连接,并且auth后,保存映射关系
message ConnectReq {
ConnectCommon comm = 1;
string roomId = 4;
string token = 5;
Platform platform = 6;
}
message ConnectReply {
HbCfg hb_cfg = 1;
}
message HbCfg {
int64 interval = 1; // 心跳间隔(s)
int64 fail_count = 2; // 心跳失败次数
}
// 断开TCP连接,删除映射关系
message DisconnectReq {
ConnectCommon comm = 1;
}
message DisconnectReply {
bool has = 1;
}
message HeartbeatReq {
ConnectCommon comm = 1;
}
message HeartbeatReply {
bool has = 1;
}
message OnlineReq {
string serverId = 1;
map<string, int32> roomCount = 2;
}
message OnlineReply {
map<string, int32> allRoomCount = 1;
}
message ReceiveReq {
uint64 userId = 1;
imfun.protocol.Proto proto = 2;
}
message ReceiveReply {
}
message NodesReq {
Platform platform = 1;
string clientIP = 2;
}
message NodesReply {
string domain = 1;
int32 tcp_port = 2;
int32 ws_port = 3;
int32 wss_port = 4;
HbCfg hb_cfg = 5;
repeated string nodes = 6;
Backoff backoff = 7;
}
message Backoff {
int32 base_delay = 1;
float multiplier = 2;
float jitter = 3;
int32 max_delay = 4;
}
// 平台
enum Platform {
Platform_None = 0;
Platform_PC = 1; // PC
Platform_Android = 2; // 安卓
Platform_Ios = 3; // IOS
Platform_Web = 4; // 网页
Platform_MinProgram = 5; // 小程序
}