forked from EQEmu/Server
-
Notifications
You must be signed in to change notification settings - Fork 2
/
eq_stream_proxy.cpp
115 lines (89 loc) · 2.26 KB
/
eq_stream_proxy.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "global_define.h"
#include "eq_stream_proxy.h"
#include "struct_strategy.h"
#include "eqemu_logsys.h"
#include "opcodemgr.h"
EQStreamProxy::EQStreamProxy(std::shared_ptr<EQStreamInterface> &stream, const StructStrategy *structs, OpcodeManager **opcodes)
: m_stream(stream),
m_structs(structs),
m_opcodes(opcodes)
{
stream = nullptr; //take the stream.
m_stream->SetOpcodeManager(m_opcodes);
}
EQStreamProxy::~EQStreamProxy() {
}
std::string EQStreamProxy::Describe() const {
return(m_structs->Describe());
}
const EQ::versions::ClientVersion EQStreamProxy::ClientVersion() const
{
return m_structs->ClientVersion();
}
EQStreamState EQStreamProxy::GetState()
{
return m_stream->GetState();
}
void EQStreamProxy::SetOpcodeManager(OpcodeManager **opm)
{
return m_stream->SetOpcodeManager(opm);
}
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
if (p == nullptr) {
return;
}
EQApplicationPacket *newp = p->Copy();
FastQueuePacket(&newp, ack_req);
}
void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) {
if(p == nullptr || *p == nullptr)
return;
m_structs->Encode(p, m_stream, ack_req);
}
EQApplicationPacket *EQStreamProxy::PopPacket() {
EQApplicationPacket *pack = m_stream->PopPacket();
if(pack == nullptr)
return(nullptr);
//pass this packet through the struct strategy.
m_structs->Decode(pack);
return(pack);
}
void EQStreamProxy::Close() {
m_stream->Close();
}
std::string EQStreamProxy::GetRemoteAddr() const {
return(m_stream->GetRemoteAddr());
}
uint32 EQStreamProxy::GetRemoteIP() const {
return(m_stream->GetRemoteIP());
}
uint16 EQStreamProxy::GetRemotePort() const {
return(m_stream->GetRemotePort());
}
void EQStreamProxy::ReleaseFromUse() {
m_stream->ReleaseFromUse();
}
void EQStreamProxy::RemoveData() {
m_stream->RemoveData();
}
EQStreamInterface::Stats EQStreamProxy::GetStats() const
{
return m_stream->GetStats();
}
void EQStreamProxy::ResetStats()
{
m_stream->ResetStats();
}
EQStreamManagerInterface *EQStreamProxy::GetManager() const
{
return m_stream->GetManager();
}
bool EQStreamProxy::CheckState(EQStreamState state) {
if(m_stream)
return(m_stream->CheckState(state));
return false;
}
OpcodeManager *EQStreamProxy::GetOpcodeManager() const
{
return (*m_opcodes);
}