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
|
|