-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtype.h
More file actions
51 lines (44 loc) · 1.04 KB
/
Copy pathtype.h
File metadata and controls
51 lines (44 loc) · 1.04 KB
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
#pragma once
#define EJSON_TAG_WITH_METHOD
#include <ejson/base64.h>
#include <ejson/parser.h>
#include <string>
namespace chat {
enum ParseState { kGetLength, kGetBody, kParseOk };
enum Code {
kRequestInit,
kRequestAllList,
kRequestChat,
kResponseInit,
kResponseAllList,
kResponseChat,
kBadResponse,
};
struct CommonData
{
int code;
std::string text;
OPTION_EJSON(code, -1)
static CommonData Bad(ejson::string_view const &sv)
{
return CommonData{kBadResponse, {sv.data(), sv.length()}};
}
void encodeText() { text = ejson::base64_encode(text); }
std::string decodeText() const { return ejson::base64_decode(text); }
};
struct ChatMsg
{
int sender;
int receiver;
std::string text;
OPTION_EJSON(sender, -1)
OPTION_EJSON(receiver, -1)
};
struct ConnectionList
{
std::vector<int> value;
};
AUTO_GEN_NON_INTRUSIVE(CommonData, code, text)
AUTO_GEN_NON_INTRUSIVE(ChatMsg, sender, receiver, text)
AUTO_GEN_NON_INTRUSIVE(ConnectionList, value)
} // namespace chat