-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
client.proto
291 lines (245 loc) · 5.71 KB
/
client.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
syntax = "proto3";
package centrifugal.centrifuge.protocol;
option go_package = "./;protocol";
message Error {
uint32 code = 1;
string message = 2;
bool temporary = 3;
}
message EmulationRequest {
string node = 1;
string session = 2;
bytes data = 3;
}
// Command sent from a client to a server.
// ProtocolVersion2 uses id and one of the possible request messages.
message Command {
// Id of command to let client match replies to commands.
uint32 id = 1;
reserved 2, 3;
// ProtocolVersion2 client can send one of the following requests. Server will
// only take the first non-null request out of these and may return an error if
// client passed more than one request. We are not using oneof here due to JSON
// interoperability concerns.
ConnectRequest connect = 4;
SubscribeRequest subscribe = 5;
UnsubscribeRequest unsubscribe = 6;
PublishRequest publish = 7;
PresenceRequest presence = 8;
PresenceStatsRequest presence_stats = 9;
HistoryRequest history = 10;
PingRequest ping = 11;
SendRequest send = 12;
RPCRequest rpc = 13;
RefreshRequest refresh = 14;
SubRefreshRequest sub_refresh = 15;
}
// Reply sent from a server to a client.
// ProtocolVersion2 uses id and one of the possible concrete result messages.
message Reply {
// Id will only be set to a value > 0 for replies to commands. For pushes
// it will have zero value.
uint32 id = 1;
// Error can only be set in replies to commands. For pushes it will have zero value.
Error error = 2;
reserved 3;
// ProtocolVersion2 server can send one of the following fields. We are not using
// oneof here due to JSON interoperability concerns.
Push push = 4;
ConnectResult connect = 5;
SubscribeResult subscribe = 6;
UnsubscribeResult unsubscribe = 7;
PublishResult publish = 8;
PresenceResult presence = 9;
PresenceStatsResult presence_stats = 10;
HistoryResult history = 11;
PingResult ping = 12;
RPCResult rpc = 13;
RefreshResult refresh = 14;
SubRefreshResult sub_refresh = 15;
}
// Push can be sent to a client as part of Reply in case of bidirectional transport or
// without additional wrapping in case of unidirectional transports.
// ProtocolVersion2 uses channel and one of the possible concrete push messages.
message Push {
reserved 1, 3;
string channel = 2;
// ProtocolVersion2 server can push one of the following fields to the client. We are
// not using oneof here due to JSON interoperability concerns.
Publication pub = 4;
Join join = 5;
Leave leave = 6;
Unsubscribe unsubscribe = 7;
Message message = 8;
Subscribe subscribe = 9;
Connect connect = 10;
Disconnect disconnect = 11;
Refresh refresh = 12;
}
message ClientInfo {
string user = 1;
string client = 2;
bytes conn_info = 3;
bytes chan_info = 4;
}
message Publication {
reserved 1, 2, 3;
bytes data = 4;
ClientInfo info = 5;
uint64 offset = 6;
map<string, string> tags = 7;
}
message Join {
ClientInfo info = 1;
}
message Leave {
ClientInfo info = 1;
}
message Unsubscribe {
reserved 1;
uint32 code = 2;
string reason = 3;
}
message Subscribe {
bool recoverable = 1;
reserved 2, 3;
string epoch = 4;
uint64 offset = 5;
bool positioned = 6;
bytes data = 7;
}
message Message {
bytes data = 1;
}
message Connect {
string client = 1;
string version = 2;
bytes data = 3;
map<string, SubscribeResult> subs = 4;
bool expires = 5;
uint32 ttl = 6;
uint32 ping = 7;
bool pong = 8;
string session = 9;
string node = 10;
}
message Disconnect {
uint32 code = 1;
string reason = 2;
bool reconnect = 3;
}
message Refresh {
bool expires = 1;
uint32 ttl = 2;
}
message ConnectRequest {
string token = 1;
bytes data = 2;
map<string, SubscribeRequest> subs = 3;
string name = 4;
string version = 5;
}
message ConnectResult {
string client = 1;
string version = 2;
bool expires = 3;
uint32 ttl = 4;
bytes data = 5;
map<string, SubscribeResult> subs = 6;
uint32 ping = 7;
bool pong = 8;
string session = 9;
string node = 10;
}
message RefreshRequest {
string token = 1;
}
message RefreshResult {
string client = 1;
string version = 2;
bool expires = 3;
uint32 ttl = 4;
}
message SubscribeRequest {
string channel = 1;
string token = 2;
bool recover = 3;
reserved 4, 5;
string epoch = 6;
uint64 offset = 7;
bytes data = 8;
bool positioned = 9;
bool recoverable = 10;
bool join_leave = 11;
}
message SubscribeResult {
bool expires = 1;
uint32 ttl = 2;
bool recoverable = 3;
reserved 4, 5;
string epoch = 6;
repeated Publication publications = 7;
bool recovered = 8;
uint64 offset = 9;
bool positioned = 10;
bytes data = 11;
bool was_recovering = 12;
}
message SubRefreshRequest {
string channel = 1;
string token = 2;
}
message SubRefreshResult {
bool expires = 1;
uint32 ttl = 2;
}
message UnsubscribeRequest {
string channel = 1;
}
message UnsubscribeResult {}
message PublishRequest {
string channel = 1;
bytes data = 2;
}
message PublishResult {}
message PresenceRequest {
string channel = 1;
}
message PresenceResult {
map<string, ClientInfo> presence = 1;
}
message PresenceStatsRequest {
string channel = 1;
}
message PresenceStatsResult {
uint32 num_clients = 1;
uint32 num_users = 2;
}
message StreamPosition {
uint64 offset = 1;
string epoch = 2;
}
message HistoryRequest {
string channel = 1;
reserved 2, 3, 4, 5, 6;
int32 limit = 7;
StreamPosition since = 8;
bool reverse = 9;
}
message HistoryResult {
repeated Publication publications = 1;
string epoch = 2;
uint64 offset = 3;
}
message PingRequest {}
message PingResult {}
message RPCRequest{
bytes data = 1;
string method = 2;
}
message RPCResult {
bytes data = 1 ;
}
message SendRequest{
bytes data = 1;
}