-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprot.h
257 lines (245 loc) · 6.17 KB
/
prot.h
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
#pragma pack(push, 1)
#define set_ProtocolVersion 0x00000000
/* command integer */
typedef uint16_t Protocol_CI_t;
struct ProtocolBasePacket_t{
uint32_t ID;
Protocol_CI_t Command;
};
struct Protocol_SessionID_t{
typedef uint32_t Type;
Type i;
Type &g(){
return i;
}
Protocol_SessionID_t() = default;
Protocol_SessionID_t(auto);
Protocol_SessionID_t(auto, auto);
bool operator==(Protocol_SessionID_t SessionID){
return g() == SessionID.g();
}
};
struct Protocol_AccountID_t{
typedef uint32_t Type;
Type i;
Type &g(){
return i;
}
Protocol_AccountID_t() = default;
Protocol_AccountID_t(auto p);
bool operator==(Protocol_AccountID_t AccountID){
return g() == AccountID.g();
}
bool operator!=(Protocol_AccountID_t AccountID){
return g() != AccountID.g();
}
static Protocol_AccountID_t GetInvalid(){
Protocol_AccountID_t r;
r.g() = (Type)-1;
return r;
}
};
struct Protocol_ChannelID_t{
typedef uint16_t Type;
Type i;
Type &g(){
return i;
}
Protocol_ChannelID_t() = default;
Protocol_ChannelID_t(auto p);
};
struct Protocol_ChannelSessionID_t{
typedef uint32_t Type;
Type i;
Type &g(){
return i;
}
Protocol_ChannelSessionID_t() = default;
Protocol_ChannelSessionID_t(auto p);
};
struct Protocol_SessionChannelID_t{
typedef Protocol_ChannelID_t::Type Type;
Type i;
Type &g(){
return i;
}
Protocol_SessionChannelID_t() = default;
Protocol_SessionChannelID_t(auto p);
};
namespace Protocol{
const uint64_t InformInvalidIdentifyAt = 1000000000;
const uint32_t ChannelType_Amount = 1;
enum{
ChannelType_ScreenShare_e
};
const uint8_t *ChannelType_Text[ChannelType_Amount] = {
(const uint8_t *)"ScreenShare"
};
enum class KickedFromChannel_Reason_t : uint8_t{
Unknown,
ChannelIsClosed
};
const char *KickedFromChannel_Reason_String[] = {
"Unknown",
"ChannelIsClosed"
};
enum class JoinChannel_Error_Reason_t : uint8_t{
InvalidChannelType,
InvalidChannelID
};
const char *JoinChannel_Error_Reason_String[] = {
"InvalidChannelType",
"InvalidChannelID"
};
enum class LoginType_t : uint8_t{
Anonymous
};
}
namespace ProtocolChannel{
namespace ScreenShare{
namespace ChannelFlag{
using _t = uint8_t;
_t InputControl = 0x01;
}
namespace StreamHeadFlag{
using _t = uint8_t;
_t KeyFrame = 0x01;
}
}
}
namespace ProtocolUDP{
struct BasePacket_t{
Protocol_SessionID_t SessionID;
uint32_t ID;
uint64_t IdentifySecret;
Protocol_CI_t Command;
};
struct C2S_t : __dme_inherit(C2S_t){
__dme(KeepAlive);
__dme(Channel_ScreenShare_Host_StreamData,
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
);
}C2S;
struct S2C_t : __dme_inherit(S2C_t){
__dme(KeepAlive);
__dme(Channel_ScreenShare_View_StreamData,
Protocol_ChannelID_t ChannelID;
);
}S2C;
}
struct Protocol_C2S_t : __dme_inherit(Protocol_C2S_t){
__dme(KeepAlive);
__dme(Request_Login,
Protocol::LoginType_t Type;
);
__dme(CreateChannel,
uint8_t Type;
);
__dme(JoinChannel,
Protocol_ChannelID_t ChannelID;
);
__dme(QuitChannel,
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
);
__dme(Response_UDPIdentifySecret,
uint64_t UDPIdentifySecret;
);
__dme(Channel_ScreenShare_Share_InformationToViewSetFlag,
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
ProtocolChannel::ScreenShare::ChannelFlag::_t Flag;
);
__dme(Channel_ScreenShare_Share_InformationToViewMouseCoordinate,
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
fan::vec2ui pos;
);
__dme(Channel_ScreenShare_View_ApplyToHostMouseCoordinate,
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
fan::vec2si pos;
);
__dme(Channel_ScreenShare_View_ApplyToHostMouseMotion,
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
fan::vec2si Motion;
);
__dme(Channel_ScreenShare_View_ApplyToHostMouseButton,
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
uint8_t key;
bool state;
fan::vec2si pos;
);
__dme(Channel_ScreenShare_View_ApplyToHostKeyboard,
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
uint16_t Scancode;
bool State;
);
}Protocol_C2S;
struct Protocol_S2C_t : __dme_inherit(Protocol_S2C_t){
__dme(KeepAlive);
__dme(InformInvalidIdentify,
uint64_t ClientIdentify;
uint64_t ServerIdentify;
);
__dme(Response_Login,
Protocol_AccountID_t AccountID;
Protocol_SessionID_t SessionID;
);
__dme(CreateChannel_OK,
uint8_t Type;
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
);
__dme(CreateChannel_Error,
Protocol::JoinChannel_Error_Reason_t Reason;
);
__dme(JoinChannel_OK,
uint8_t Type;
Protocol_ChannelID_t ChannelID;
Protocol_ChannelSessionID_t ChannelSessionID;
);
__dme(JoinChannel_Error,
Protocol::JoinChannel_Error_Reason_t Reason;
);
__dme(KickedFromChannel,
Protocol_ChannelID_t ChannelID;
Protocol::KickedFromChannel_Reason_t Reason;
);
__dme(Request_UDPIdentifySecret);
__dme(UseThisUDPIdentifySecret,
uint64_t UDPIdentifySecret;
);
__dme(Channel_ScreenShare_View_InformationToViewSetFlag,
Protocol_ChannelID_t ChannelID;
ProtocolChannel::ScreenShare::ChannelFlag::_t Flag;
);
__dme(Channel_ScreenShare_View_InformationToViewMouseCoordinate,
Protocol_ChannelID_t ChannelID;
fan::vec2ui pos;
);
__dme(Channel_ScreenShare_Share_ApplyToHostMouseCoordinate,
Protocol_ChannelID_t ChannelID;
fan::vec2si pos;
);
__dme(Channel_ScreenShare_Share_ApplyToHostMouseMotion,
Protocol_ChannelID_t ChannelID;
fan::vec2si Motion;
);
__dme(Channel_ScreenShare_Share_ApplyToHostMouseButton,
Protocol_ChannelID_t ChannelID;
uint8_t key;
bool state;
fan::vec2si pos;
);
__dme(Channel_ScreenShare_Share_ApplyToHostKeyboard,
Protocol_ChannelID_t ChannelID;
uint16_t Scancode;
uint8_t State;
);
}Protocol_S2C;
#pragma pack(pop)