-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdto.h
62 lines (49 loc) · 1.02 KB
/
dto.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
#pragma once
#include "binary.h"
#include <vector>
#include <winsock.h>
// 应用层协议
// 定义了各种请求、响应的具体内容及其序列化方式
struct GetTimeRequest {};
SERIALIZER0(GetTimeRequest);
struct GetTimeResponse {
time_t time;
};
SERIALIZER1(GetTimeResponse, time);
struct GetNameRequest {};
SERIALIZER0(GetNameRequest);
struct GetNameResponse {
std::string name;
};
SERIALIZER1(GetNameResponse, name);
struct GetListRequest {};
SERIALIZER0(GetListRequest);
struct GetListResponse {
struct ListItem
{
int id;
std::string addr;
int port;
// 端口
// 地址
};
std::vector<ListItem> items;
};
SERIALIZER3(GetListResponse::ListItem, id, addr, port);
SERIALIZER1(GetListResponse, items);
struct SendMessageRequest
{
int id;
std::string str;
};
SERIALIZER2(SendMessageRequest, id, str);
struct SendMessageResponse
{
bool is_sent;
};
SERIALIZER1(SendMessageResponse, is_sent);
struct ReceivedMessage
{
std::string str;
};
SERIALIZER1(ReceivedMessage, str);