EvEmu
0.8.4
11 September 2021
|
EVE derivation of TCP connection. More...
#include "EVETCPConnection.h"
Public Types | |
enum | packet_direction { PACKET_INBOUND, PACKET_OUTBOUND } |
Dumps buffer to file. More... | |
![]() | |
enum | state_t { STATE_DISCONNECTED, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTING } |
Public Member Functions | |
EVETCPConnection () | |
Creates empty EVE connection. More... | |
virtual | ~EVETCPConnection () |
void | QueueRep (const PyRep *rep, bool compress=true) |
Queues given PyRep into send queue. More... | |
PyRep * | PopRep () |
Pops PyRep from receive queue. More... | |
void | DumpBuffer (Buffer *buf, packet_direction packet_direction) |
![]() | |
TCPConnection () | |
Creates new connection in STATE_DISCONNECTED. More... | |
virtual | ~TCPConnection () |
Cleans connection up. More... | |
uint32 | GetrIP () const |
uint16 | GetrPort () const |
std::string | GetAddress () |
state_t | GetState () const |
bool | Connect (uint32 rIP, uint16 rPort, char *errbuf=0) |
Connects to specified address. More... | |
void | AsyncConnect (uint32 rIP, uint16 rPort) |
Schedules asynchronous connect to specified address. More... | |
void | Disconnect () |
Schedules disconnect of current connection. More... | |
bool | Send (Buffer **data) |
Enqueues data to be sent. More... | |
Static Public Attributes | |
static const uint32 | TIMEOUT_MS = 10 * 60 * 1000 |
Time (in milliseconds) after which the connection is dropped if no data were received. More... | |
static const uint32 | PACKET_SIZE_LIMIT = 1024 * 1024 |
Hardcoded limit of packet size (NetClient.dll). More... | |
Protected Member Functions | |
EVETCPConnection (Socket *sock, uint32 rIP, uint16 rPort) | |
Creates new EVE connection from existing socket. More... | |
bool | RecvData (char *errbuf=0) |
Receives data and puts them into receive queue. More... | |
bool | ProcessReceivedData (char *errbuf=0) |
Processes received data. More... | |
void | ClearBuffers () |
Clears send and receive buffers. More... | |
![]() | |
TCPConnection (Socket *sock, uint32 rIP, uint16 rPort) | |
Creates connection from an existing socket. More... | |
void | StartLoop () |
Starts working thread. More... | |
void | WaitLoop () |
Blocks calling thread until working thread terminates. More... | |
virtual bool | Process () |
Does all stuff that needs to be periodically done to keep connection alive. More... | |
virtual bool | SendData (char *errbuf=0) |
Sends data in send queue. More... | |
void | DoDisconnect () |
Disconnects socket. More... | |
void | TCPConnectionLoop () |
Loop for worker threads. More... | |
Protected Attributes | |
Timer | mTimeoutTimer |
Timer used to implement timeout. More... | |
Mutex | mMInQueue |
Mutex to protect received data queue. More... | |
StreamPacketizer | mInQueue |
Received data queue. More... | |
![]() | |
Mutex | mMSock |
Socket * | mSock |
state_t | mSockState |
uint32 | mrIP |
uint16 | mrPort |
Mutex | mMLoopRunning |
Mutex | mMSendQueue |
std::deque< Buffer * > | mSendQueue |
Buffer * | mRecvBuf |
Friends | |
class | EVETCPServer |
Additional Inherited Members | |
![]() | |
static void * | TCPConnectionLoop (void *arg) |
Loop for worker threads. More... | |
EVE derivation of TCP connection.
Definition at line 37 of file EVETCPConnection.h.
Dumps buffer to file.
[in] | buf | Buffer |
[in] | direction | Direction of packet inBound/outBound |
Enumerator | |
---|---|
PACKET_INBOUND | |
PACKET_OUTBOUND |
Definition at line 75 of file EVETCPConnection.h.
EVETCPConnection::EVETCPConnection | ( | ) |
Creates empty EVE connection.
Definition at line 38 of file EVETCPConnection.cpp.
|
inlinevirtual |
Definition at line 52 of file EVETCPConnection.h.
Creates new EVE connection from existing socket.
[in] | sock | Socket to be used for connection. |
[in] | rIP | Remote IP the socket is connected to. |
[in] | rPort | Remote TCP port the socket is connected to. |
Definition at line 44 of file EVETCPConnection.cpp.
|
protectedvirtual |
Clears send and receive buffers.
Reimplemented from TCPConnection.
Definition at line 135 of file EVETCPConnection.cpp.
References StreamPacketizer::ClearBuffers(), TCPConnection::ClearBuffers(), mInQueue, mMInQueue, mTimeoutTimer, and Timer::Start().
void EVETCPConnection::DumpBuffer | ( | Buffer * | buf, |
packet_direction | packet_direction | ||
) |
Definition at line 143 of file EVETCPConnection.cpp.
References Buffer::begin(), Buffer::end(), and PACKET_INBOUND.
PyRep * EVETCPConnection::PopRep | ( | ) |
Pops PyRep from receive queue.
Definition at line 84 of file EVETCPConnection.cpp.
References InflateUnmarshal(), mInQueue, mMInQueue, PACKET_SIZE_LIMIT, StreamPacketizer::PopPacket(), SafeDelete(), Buffer::size(), and sLog.
Referenced by EVEClientSession::PopPacket().
|
protectedvirtual |
Processes received data.
This function must be overloaded by children to process received data. Called every time a chunk of new data is received. Please note that receive buffer is overwritten every time data is received.
[out] | errbuf | Buffer which receives description of error. |
Implements TCPConnection.
Definition at line 105 of file EVETCPConnection.cpp.
References StreamPacketizer::InputData(), mInQueue, mMInQueue, TCPConnection::mRecvBuf, mTimeoutTimer, StreamPacketizer::Process(), and Timer::Start().
void EVETCPConnection::QueueRep | ( | const PyRep * | rep, |
bool | compress = true |
||
) |
Queues given PyRep into send queue.
[in] | rep | PyRep to be queued. |
Definition at line 50 of file EVETCPConnection.cpp.
References Buffer::end(), MarshalDeflate(), PACKET_SIZE_LIMIT, PySafeDecRef, Buffer::ResizeAt(), SafeDelete(), TCPConnection::Send(), Buffer::size(), and sLog.
Referenced by EVEClientSession::_HandleCommand(), Client::_LoginFail(), Client::_VerifyCrypto(), Client::_VerifyFuncResult(), Client::_VerifyLogin(), EVEClientSession::QueuePacket(), and EVEClientSession::Reset().
|
protectedvirtual |
Receives data and puts them into receive queue.
[out] | errbuf | Buffer which receives description of error. |
Reimplemented from TCPConnection.
Definition at line 121 of file EVETCPConnection.cpp.
References Timer::Check(), mTimeoutTimer, TCPConnection::RecvData(), snprintf, and TCPCONN_ERRBUF_SIZE.
|
friend |
Definition at line 40 of file EVETCPConnection.h.
|
protected |
Received data queue.
Definition at line 103 of file EVETCPConnection.h.
Referenced by ClearBuffers(), PopRep(), and ProcessReceivedData().
|
protected |
Mutex to protect received data queue.
Definition at line 101 of file EVETCPConnection.h.
Referenced by ClearBuffers(), PopRep(), and ProcessReceivedData().
|
protected |
Timer used to implement timeout.
Definition at line 98 of file EVETCPConnection.h.
Referenced by ClearBuffers(), ProcessReceivedData(), and RecvData().
|
static |
Hardcoded limit of packet size (NetClient.dll).
Definition at line 46 of file EVETCPConnection.h.
Referenced by PopRep(), and QueueRep().
|
static |
Time (in milliseconds) after which the connection is dropped if no data were received.
Definition at line 44 of file EVETCPConnection.h.