line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
MODE: INLINE |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
enum class Status07 { CONNECTED = 1, AUTHORIZED = 2, NOT_AUTHORIZED = 3, DISCONNECTED = 4 }; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
struct Client07 { |
8
|
|
|
|
|
|
|
int id; |
9
|
|
|
|
|
|
|
Status07 status; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Client07 (int id_): id{id_}, status{Status07::CONNECTED } {} |
12
|
|
|
|
|
|
|
void disconnect() { |
13
|
|
|
|
|
|
|
std::cout << "disconnecting " << id << "\n"; |
14
|
|
|
|
|
|
|
status = Status07::DISCONNECTED; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
void welcome() { |
17
|
|
|
|
|
|
|
std::cout << "[sending] welcome dear client " << id << "\n"; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
struct ServerBase07 { |
22
|
|
|
|
|
|
|
void on_client(Client07* c) { |
23
|
|
|
|
|
|
|
if (c->status == Status07::AUTHORIZED) c->welcome(); |
24
|
|
|
|
|
|
|
if (c->status == Status07::NOT_AUTHORIZED) c->disconnect(); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
struct LoggerPlugin07 { |
29
|
|
|
|
|
|
|
void on_client(Client07* c) { std::cout << "client " << c->id << ", status: " << (int) c->status << "\n"; } |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
struct AuthorizerPlugin07 { |
33
|
|
|
|
|
|
|
void on_client(Client07* c) { |
34
|
|
|
|
|
|
|
c->status = (c->id < 0) ? Status07::NOT_AUTHORIZED : Status07::AUTHORIZED; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
namespace xs { |
39
|
|
|
|
|
|
|
template <> |
40
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
41
|
|
|
|
|
|
|
static std::string package () { return "MyTest::Cookbook::Client07"; } |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
template <> |
45
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
46
|
|
|
|
|
|
|
static std::string package () { return "MyTest::Cookbook::ServerBase07"; } |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
template <> |
50
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
51
|
|
|
|
|
|
|
static std::string package () { return "MyTest::Cookbook::LoggerPlugin07"; } |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
template <> |
55
|
|
|
|
|
|
|
struct Typemap : TypemapObject { |
56
|
|
|
|
|
|
|
static std::string package () { return "MyTest::Cookbook::AuthorizerPlugin07"; } |
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::Client07 |
63
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
void Client07::disconnect() |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
void Client07::welcome() |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
Client07* Client07::new(int id) |
70
|
0
|
0
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
|
72
|
|
|
|
|
|
|
MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::ServerBase07 |
73
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
void ServerBase07::on_client(Client07* c) |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
ServerBase07* ServerBase07::new() |
78
|
0
|
0
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::LoggerPlugin07 |
80
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
void LoggerPlugin07::on_client(Client07* c) { |
83
|
0
|
|
|
|
|
|
THIS->on_client(c); |
84
|
0
|
0
|
|
|
|
|
Object(ST(0)).call_next(cv, &ST(1), items-1); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
THIS->on_client(c); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
LoggerPlugin07* LoggerPlugin07::new (...) { |
89
|
0
|
|
|
|
|
|
PROTO = Stash::from_name(CLASS).call_next(cv, &ST(1), items-1); |
90
|
0
|
0
|
|
|
|
|
if (!PROTO.defined()) XSRETURN_UNDEF; |
91
|
0
|
0
|
|
|
|
|
RETVAL = new LoggerPlugin07(); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
} |
93
|
0
|
0
|
|
|
|
|
|
94
|
|
|
|
|
|
|
MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::AuthorizerPlugin07 |
95
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
void AuthorizerPlugin07::on_client(Client07* c) { |
98
|
0
|
|
|
|
|
|
THIS->on_client(c); |
99
|
0
|
0
|
|
|
|
|
Object(ST(0)).call_next(cv, &ST(1), items-1); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
AuthorizerPlugin07* AuthorizerPlugin07::new (...) { |
103
|
0
|
|
|
|
|
|
PROTO = Stash::from_name(CLASS).call_next(cv, &ST(1), items-1); |
104
|
0
|
0
|
|
|
|
|
if (!PROTO.defined()) XSRETURN_UNDEF; |
105
|
0
|
0
|
|
|
|
|
RETVAL = new AuthorizerPlugin07(); |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
} |
107
|
0
|
0
|
|
|
|
|
|
108
|
|
|
|
|
|
|
MODULE = MyTest::Cookbook PACKAGE = MyTest::Cookbook::Server07 |
109
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
BOOT { |
112
|
68
|
50
|
|
|
|
|
auto stash = Stash(__PACKAGE__, GV_ADD); |
113
|
34
|
50
|
|
|
|
|
stash.inherit("MyTest::Cookbook::LoggerPlugin07"); |
114
|
34
|
50
|
|
|
|
|
stash.inherit("MyTest::Cookbook::AuthorizerPlugin07"); |
115
|
34
|
50
|
|
|
|
|
stash.inherit("MyTest::Cookbook::ServerBase07"); |
116
|
|
|
|
|
|
|
} |