ManaPlus
|
#include <network.h>
Public Types | |
enum | { IDLE = 0 , CONNECTED , CONNECTING , DATA , NET_ERROR } |
Public Member Functions | |
Network () | |
virtual | ~Network () |
bool | connect (const ServerInfo &server) |
void | disconnect () |
ServerInfo | getServer () const |
int | getState () const |
const std::string & | getError () const |
bool | isConnected () const |
int | getInSize () const |
void | skip (const int len) |
void | flush () |
void | fixSendBuffer () |
void | pauseDispatch () |
Protected Member Functions | |
void | setError (const std::string &error) |
uint16_t | readWord (const int pos) const |
bool | realConnect () |
void | receive () |
Protected Attributes | |
TcpNet::Socket | mSocket |
ServerInfo | mServer |
PacketInfo * | mPackets |
char * | mInBuffer |
char * | mOutBuffer |
unsigned int | mInSize |
unsigned int | mOutSize |
unsigned int | mToSkip |
int | mState |
std::string | mError |
SDL_Thread * | mWorkerThread |
SDL_mutex * | mMutexIn |
SDL_mutex * | mMutexOut |
int | mSleep |
bool | mPauseDispatch |
Friends | |
int | networkThread (void *data) |
anonymous enum |
Ea::Network::Network | ( | ) |
Definition at line 64 of file network.cpp.
References TcpNet::init().
|
virtual |
Reimplemented in TmwAthena::Network, and EAthena::Network.
Definition at line 84 of file network.cpp.
References delete2Arr, disconnect(), IDLE, mInBuffer, mMutexIn, mMutexOut, mOutBuffer, mPackets, mState, NET_ERROR, and TcpNet::quit().
bool Ea::Network::connect | ( | const ServerInfo & | server | ) |
Definition at line 101 of file network.cpp.
References _, ServerInfo::althostname, CONNECTING, SDL::createThread(), ServerInfo::hostname, IDLE, Logger::log(), Logger::log1(), logger, mInSize, mOutSize, mServer, mState, mToSkip, mWorkerThread, NET_ERROR, networkThread, ServerInfo::port, and setError().
Referenced by EAthena::CharServerHandler::connect(), EAthena::GameHandler::connect(), EAthena::LoginHandler::connect(), TmwAthena::CharServerHandler::connect(), TmwAthena::GameHandler::connect(), and TmwAthena::LoginHandler::connect().
void Ea::Network::disconnect | ( | ) |
Definition at line 139 of file network.cpp.
References BLOCK_END, BLOCK_START, TcpNet::closeSocket(), IDLE, mSleep, mSocket, mState, mWorkerThread, and SDL::WaitThread().
Referenced by EAthena::CharServerHandler::connect(), TmwAthena::CharServerHandler::connect(), EAthena::GameHandler::disconnect(), EAthena::LoginHandler::disconnect(), TmwAthena::GameHandler::disconnect(), TmwAthena::LoginHandler::disconnect(), EAthena::CharServerRecv::processChangeMapServer(), TmwAthena::CharServerRecv::processChangeMapServer(), EAthena::CharServerRecv::processCharMapInfo(), TmwAthena::CharServerRecv::processCharMapInfo(), EAthena::GeneralHandler::reload(), TmwAthena::GeneralHandler::reload(), and ~Network().
void Ea::Network::fixSendBuffer | ( | ) |
Definition at line 362 of file network.cpp.
References Ea::BUFFER_LIMIT, CONNECTED, flush(), mOutSize, and mState.
Referenced by EAthena::MessageOut::MessageOut(), and TmwAthena::MessageOut::MessageOut().
void Ea::Network::flush | ( | ) |
Definition at line 157 of file network.cpp.
References CAST_S32, CONNECTED, TcpNet::getError(), mMutexOut, mOutBuffer, mOutSize, mSocket, mState, TcpNet::send(), and setError().
Referenced by fixSendBuffer(), EAthena::GeneralHandler::flushNetwork(), TmwAthena::GeneralHandler::flushNetwork(), EAthena::GeneralHandler::flushSend(), and TmwAthena::GeneralHandler::flushSend().
|
inline |
Definition at line 58 of file network.h.
References mError.
Referenced by EAthena::GeneralHandler::flushNetwork(), and TmwAthena::GeneralHandler::flushNetwork().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 61 of file network.h.
References CONNECTED, and mState.
Referenced by EAthena::GameHandler::isConnected(), EAthena::LoginHandler::isConnected(), TmwAthena::GameHandler::isConnected(), and TmwAthena::LoginHandler::isConnected().
|
inline |
Definition at line 73 of file network.h.
References mPauseDispatch.
Referenced by EAthena::GameRecv::processMapLogin(), and TmwAthena::GameRecv::processMapLogin().
|
protected |
Definition at line 350 of file network.cpp.
References CAST_SIZE, and mInBuffer.
Referenced by EAthena::Network::dispatchMessages(), TmwAthena::Network::dispatchMessages(), EAthena::Network::messageReady(), and TmwAthena::Network::messageReady().
|
protected |
Definition at line 205 of file network.cpp.
References _, ServerInfo::althostname, CONNECTED, CONNECTING, errorMessage, TcpNet::getError(), ServerInfo::hostname, ipToString(), Logger::log_r(), logger, mLastHost, mServer, mSocket, mState, TcpNet::open(), ServerInfo::port, TcpNet::resolveHost(), and setError().
|
protected |
Definition at line 244 of file network.cpp.
References _, TcpNet::addSocket(), TcpNet::allocSocketSet(), Ea::BUFFER_LIMIT, Ea::BUFFER_SIZE, CAST_SIZE, CAST_U32, TcpNet::checkSockets(), CONNECTED, TcpNet::delSocket(), TcpNet::freeSocketSet(), TcpNet::getError(), IDLE, Logger::log_r(), logger, mInBuffer, mInSize, mMutexIn, mSocket, mState, mToSkip, TcpNet::recv(), and setError().
|
protected |
Definition at line 343 of file network.cpp.
References Actions::error(), Logger::log_r(), logger, mError, mState, and NET_ERROR.
Referenced by connect(), flush(), realConnect(), and receive().
void Ea::Network::skip | ( | const int | len | ) |
Definition at line 181 of file network.cpp.
References CAST_SIZE, mInBuffer, mInSize, mMutexIn, and mToSkip.
Referenced by EAthena::CharServerHandler::connect(), TmwAthena::CharServerHandler::connect(), TmwAthena::GameHandler::connect(), EAthena::Network::dispatchMessages(), and TmwAthena::Network::dispatchMessages().
|
friend |
|
protected |
Definition at line 111 of file network.h.
Referenced by getError(), and setError().
|
protected |
Definition at line 103 of file network.h.
Referenced by EAthena::Network::dispatchMessages(), TmwAthena::Network::dispatchMessages(), readWord(), receive(), skip(), and ~Network().
|
protected |
Definition at line 105 of file network.h.
Referenced by connect(), getInSize(), EAthena::Network::messageReady(), TmwAthena::Network::messageReady(), receive(), and skip().
|
protected |
Definition at line 114 of file network.h.
Referenced by EAthena::Network::dispatchMessages(), TmwAthena::Network::dispatchMessages(), EAthena::Network::messageReady(), TmwAthena::Network::messageReady(), receive(), skip(), and ~Network().
|
protected |
Definition at line 115 of file network.h.
Referenced by flush(), and ~Network().
|
protected |
Definition at line 104 of file network.h.
Referenced by flush(), EAthena::MessageOut::MessageOut(), TmwAthena::MessageOut::MessageOut(), and ~Network().
|
protected |
Definition at line 106 of file network.h.
Referenced by connect(), EAthena::MessageOut::expand(), TmwAthena::MessageOut::expand(), fixSendBuffer(), flush(), EAthena::MessageOut::MessageOut(), and TmwAthena::MessageOut::MessageOut().
|
protected |
Definition at line 101 of file network.h.
Referenced by EAthena::Network::clearHandlers(), TmwAthena::Network::clearHandlers(), EAthena::Network::dispatchMessages(), TmwAthena::Network::dispatchMessages(), EAthena::Network::messageReady(), TmwAthena::Network::messageReady(), EAthena::Network::Network(), TmwAthena::Network::Network(), EAthena::Network::registerFakeHandlers(), and ~Network().
|
protected |
Definition at line 117 of file network.h.
Referenced by EAthena::Network::dispatchMessages(), TmwAthena::Network::dispatchMessages(), and pauseDispatch().
|
protected |
Definition at line 99 of file network.h.
Referenced by connect(), getServer(), and realConnect().
|
protected |
Definition at line 116 of file network.h.
Referenced by disconnect().
|
protected |
Definition at line 97 of file network.h.
Referenced by disconnect(), flush(), realConnect(), and receive().
|
protected |
Definition at line 110 of file network.h.
Referenced by connect(), disconnect(), fixSendBuffer(), flush(), getState(), isConnected(), realConnect(), receive(), setError(), and ~Network().
|
protected |
|
protected |
Definition at line 113 of file network.h.
Referenced by connect(), and disconnect().