2013-02-16 16:14:39 -08:00
|
|
|
|
2015-01-19 04:12:09 -06:00
|
|
|
#include "global_define.h"
|
2014-08-21 19:33:02 -07:00
|
|
|
#include "eq_stream_proxy.h"
|
|
|
|
|
#include "struct_strategy.h"
|
2017-07-07 14:59:01 -05:00
|
|
|
#include "eqemu_logsys.h"
|
|
|
|
|
#include "opcodemgr.h"
|
2013-02-16 16:14:39 -08:00
|
|
|
|
|
|
|
|
|
2016-09-24 22:43:29 -07:00
|
|
|
EQStreamProxy::EQStreamProxy(std::shared_ptr<EQStreamInterface> &stream, const StructStrategy *structs, OpcodeManager **opcodes)
|
2013-05-09 10:44:08 -04:00
|
|
|
: m_stream(stream),
|
|
|
|
|
m_structs(structs),
|
|
|
|
|
m_opcodes(opcodes)
|
2013-02-16 16:14:39 -08:00
|
|
|
{
|
2013-05-04 18:06:58 -07:00
|
|
|
stream = nullptr; //take the stream.
|
2013-02-16 16:14:39 -08:00
|
|
|
m_stream->SetOpcodeManager(m_opcodes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EQStreamProxy::~EQStreamProxy() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string EQStreamProxy::Describe() const {
|
|
|
|
|
return(m_structs->Describe());
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-17 18:36:06 -07:00
|
|
|
const EQ::versions::ClientVersion EQStreamProxy::ClientVersion() const
|
2013-02-17 18:09:31 +00:00
|
|
|
{
|
2016-04-22 03:49:17 -04:00
|
|
|
return m_structs->ClientVersion();
|
2013-02-17 18:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-24 22:43:29 -07:00
|
|
|
EQStreamState EQStreamProxy::GetState()
|
|
|
|
|
{
|
|
|
|
|
return m_stream->GetState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EQStreamProxy::SetOpcodeManager(OpcodeManager **opm)
|
|
|
|
|
{
|
|
|
|
|
return m_stream->SetOpcodeManager(opm);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-16 16:14:39 -08:00
|
|
|
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
|
2013-05-04 18:06:58 -07:00
|
|
|
if(p == nullptr)
|
2013-02-16 16:14:39 -08:00
|
|
|
return;
|
2013-05-06 13:07:41 -04:00
|
|
|
|
2017-07-07 14:59:01 -05:00
|
|
|
if (p->GetOpcode() != OP_SpecialMesg) {
|
2019-09-01 20:47:26 -05:00
|
|
|
Log(Logs::General, Logs::PacketServerClient, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size());
|
|
|
|
|
Log(Logs::General, Logs::PacketServerClientWithDump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str());
|
2017-07-07 14:59:01 -05:00
|
|
|
}
|
|
|
|
|
|
2013-02-16 16:14:39 -08:00
|
|
|
EQApplicationPacket *newp = p->Copy();
|
|
|
|
|
FastQueuePacket(&newp, ack_req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) {
|
2013-05-04 18:06:58 -07:00
|
|
|
if(p == nullptr || *p == nullptr)
|
2013-02-16 16:14:39 -08:00
|
|
|
return;
|
|
|
|
|
m_structs->Encode(p, m_stream, ack_req);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EQApplicationPacket *EQStreamProxy::PopPacket() {
|
|
|
|
|
EQApplicationPacket *pack = m_stream->PopPacket();
|
2013-05-04 18:06:58 -07:00
|
|
|
if(pack == nullptr)
|
|
|
|
|
return(nullptr);
|
2013-05-06 13:07:41 -04:00
|
|
|
|
2013-02-16 16:14:39 -08:00
|
|
|
//pass this packet through the struct strategy.
|
|
|
|
|
m_structs->Decode(pack);
|
|
|
|
|
return(pack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EQStreamProxy::Close() {
|
|
|
|
|
m_stream->Close();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 19:02:03 -07:00
|
|
|
std::string EQStreamProxy::GetRemoteAddr() const {
|
|
|
|
|
return(m_stream->GetRemoteAddr());
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-16 16:14:39 -08:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-11 15:24:32 -07:00
|
|
|
EQStreamInterface::Stats EQStreamProxy::GetStats() const
|
|
|
|
|
{
|
|
|
|
|
return m_stream->GetStats();
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 22:55:49 -07:00
|
|
|
void EQStreamProxy::ResetStats()
|
|
|
|
|
{
|
|
|
|
|
m_stream->ResetStats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EQStreamManagerInterface *EQStreamProxy::GetManager() const
|
|
|
|
|
{
|
|
|
|
|
return m_stream->GetManager();
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-16 16:14:39 -08:00
|
|
|
bool EQStreamProxy::CheckState(EQStreamState state) {
|
|
|
|
|
if(m_stream)
|
|
|
|
|
return(m_stream->CheckState(state));
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|