-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameChannel.cpp
More file actions
50 lines (36 loc) · 890 Bytes
/
GameChannel.cpp
File metadata and controls
50 lines (36 loc) · 890 Bytes
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
#include "GameChannel.h"
GameChannel::GameChannel(int _fd) :ZinxTcpData(_fd)
{
}
GameChannel::~GameChannel()
{
if (NULL != m_proto)
{
ZinxKernel::Zinx_Del_Proto(*m_proto);
delete m_proto;
}
}
AZinxHandler* GameChannel::GetInputNextStage(BytesMsg& _oInput)
{
return m_proto;
}
ZinxTcpData* GameConnFact::CreateTcpDataChannel(int _fd)
{
/*创建tcp通道对象*/
auto pChannel = new GameChannel(_fd);
/*创建协议对象*/
auto pProtocol = new GameProtocol();
/*创建角色对象*/
auto pRole = new GameRole();
/*协议和通道绑定*/
pChannel->m_proto = pProtocol;
pProtocol->m_channel = pChannel;
/*协议和角色绑定*/
pProtocol->m_role = pRole;
pRole->m_protocol = pProtocol;
/*将协议对象添加到kernel*/
ZinxKernel::Zinx_Add_Proto(*pProtocol);
/*将玩家对象添加到kernel*/
ZinxKernel::Zinx_Add_Role(*pRole);
return pChannel;
}