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
| #ifndef TCPDATATYPE_H
| #define TCPDATATYPE_H
| /* */
| enum class ActionType
| {
| HeartCheck = 100,
| Login = 110,
| Register = 120,
| Msg = 200,
| Download = 300
| };
| /* ο HTTP Ӧ */
| enum class ResponseCode
| {
| ResponseOK = 200, // ɹ
| BadRequest = 400, // ͻ
| Unauthorized = 401, // Ҫ û ֤
| Forbidden = 403, // ͻ ˵ Ǿܾ ִ д
| NotFound = 404, // ҵ Դ
| MethodNotAllowed = 405 // ͻ еķ ֹ
|
| };
| /* Ϣ */
| struct Head
| {
| ActionType type;
| int len;
| int version;
| Head(ActionType ptype, int plen, int pversion)
| {
| len = plen;
| type = ptype;
| version = pversion;
| }
| };
| struct HeartCheckReq //
| {
| ActionType type;
| int len;
| HeartCheckReq()
| {
| type = ActionType::HeartCheck;
| len = sizeof(HeartCheckReq);
| }
| };
|
| struct HeartCheckRes // Ӧ
| {
| ActionType type;
| int len;
| HeartCheckRes()
| {
| type = ActionType::HeartCheck;
| len = sizeof(HeartCheckRes);
| }
| };
| struct RegisterRequest
| {
| Head head;
| char name[64];
| char password[64];
| char email[32];
| char phone[32];
| };
| struct LoginRequest
| {
|
| Head head;
| char name[64];
| char password[64];
| };
| #endif
|
|