-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathechorole.cpp
100 lines (82 loc) · 1.62 KB
/
echorole.cpp
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "echorole.h"
#include"cmdmsg.h"
#include"cmdcheck.h"
#include<ctime>
echo::echo()
{
}
echo::~echo()
{
}
bool echo::Init()
{
return true;
}
UserData *echo::ProcMsg(UserData &_poUserData)
{
GET_REF2DATA(cmdmsg,input, _poUserData);
cmdmsg *temp = new cmdmsg(input);
ZinxKernel::Zinx_SendOut(*temp, *(cmdcheck::getInstance()));
return nullptr;//返回的是下一个处理环节,这里暂时不需要返回nullptr
}
void echo::Fini()
{
}
bool inoutcontrol::Init()
{
return true;
}
UserData *inoutcontrol::ProcMsg(UserData &_poUserData)
{
GET_REF2DATA(cmdmsg, info, _poUserData);
if(info.isopen)
{
ZinxKernel::Zinx_Add_Channel(*inout);
}
else
{
auto p = ZinxKernel::Zinx_GetChannel_ByInfo("stdout");
inout = p;
ZinxKernel::Zinx_Del_Channel(*p);
}
return nullptr;
}
void inoutcontrol::Fini()
{
}
bool dateecho::Init()
{
Irole *ir = nullptr;
for(auto &i:ZinxKernel::Zinx_GetAllRole())
{
if(dynamic_cast<echo*>(i) != nullptr)
{
ir = i;
}
}
SetNextProcessor(*ir);
return true;
}
UserData *dateecho::ProcMsg(UserData &_poUserData)
{
GET_REF2DATA(cmdmsg, msg, _poUserData);
if(msg.iscmd && msg.isdate)
{
time_t cctime = time(nullptr);
tm* ttime = localtime(&cctime);
string curtime = string(asctime(ttime)) + msg.msg;
auto mmsg = new cmdmsg;
mmsg->msg = curtime;
return mmsg;
}
else
{
auto mmsg = new cmdmsg;
mmsg->msg = msg.msg;
return mmsg;
}
return nullptr;
}
void dateecho::Fini()
{
}