Mana
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
TmwAthena::Network Class Reference

#include <network.h>

Public Types

enum  {
  IDLE , CONNECTED , CONNECTING , DATA ,
  NET_ERROR
}
 

Public Member Functions

 Network ()
 
 ~Network ()
 
bool connect (const ServerInfo &server)
 
void disconnect ()
 
const ServerInfogetServer () const
 
void registerHandler (MessageHandler *handler)
 
void unregisterHandler (MessageHandler *handler)
 
void clearHandlers ()
 
const char * messageName (uint16_t id) const
 
int getState () const
 
const std::string & getError () const
 
bool isConnected () const
 
int getInSize () const
 
void skip (int len)
 
void dispatchMessages ()
 
void flush ()
 

Private Member Functions

void setError (const std::string &error)
 
uint16_t readWord (int pos)
 
bool realConnect ()
 
void receive ()
 

Private Attributes

TCPsocket mSocket = nullptr
 
ServerInfo mServer
 
char * mInBuffer
 
char * mOutBuffer
 
unsigned int mInSize = 0
 
unsigned int mOutSize = 0
 
unsigned int mToSkip = 0
 
int mState = IDLE
 
std::string mError
 
SDL_Thread * mWorkerThread = nullptr
 
Mutex mMutex
 
std::unordered_map< uint16_t, const PacketInfo * > mPacketInfo
 
std::map< uint16_t, MessageHandler * > mMessageHandlers
 

Static Private Attributes

static NetworkmInstance = nullptr
 

Friends

class MessageOut
 
int networkThread (void *data)
 

Detailed Description

Definition at line 49 of file network.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
IDLE 
CONNECTED 
CONNECTING 
DATA 
NET_ERROR 

Definition at line 86 of file network.h.

Constructor & Destructor Documentation

◆ Network()

TmwAthena::Network::Network ( )

Definition at line 248 of file network.cpp.

◆ ~Network()

TmwAthena::Network::~Network ( )

Definition at line 263 of file network.cpp.

Member Function Documentation

◆ clearHandlers()

void TmwAthena::Network::clearHandlers ( )

Definition at line 348 of file network.cpp.

◆ connect()

bool TmwAthena::Network::connect ( const ServerInfo server)

Definition at line 278 of file network.cpp.

◆ disconnect()

void TmwAthena::Network::disconnect ( )

Definition at line 315 of file network.cpp.

◆ dispatchMessages()

void TmwAthena::Network::dispatchMessages ( )

Definition at line 365 of file network.cpp.

◆ flush()

void TmwAthena::Network::flush ( )

Definition at line 428 of file network.cpp.

◆ getError()

const std::string & TmwAthena::Network::getError ( ) const
inline

Definition at line 73 of file network.h.

◆ getInSize()

int TmwAthena::Network::getInSize ( ) const
inline

Definition at line 77 of file network.h.

◆ getServer()

const ServerInfo & TmwAthena::Network::getServer ( ) const
inline

Definition at line 60 of file network.h.

◆ getState()

int TmwAthena::Network::getState ( ) const
inline

Definition at line 71 of file network.h.

◆ isConnected()

bool TmwAthena::Network::isConnected ( ) const
inline

Definition at line 75 of file network.h.

◆ messageName()

const char * TmwAthena::Network::messageName ( uint16_t  id) const

Definition at line 356 of file network.cpp.

◆ readWord()

uint16_t TmwAthena::Network::readWord ( int  pos)
private

Definition at line 592 of file network.cpp.

◆ realConnect()

bool TmwAthena::Network::realConnect ( )
private

Definition at line 465 of file network.cpp.

◆ receive()

void TmwAthena::Network::receive ( )
private

Definition at line 497 of file network.cpp.

◆ registerHandler()

void TmwAthena::Network::registerHandler ( MessageHandler handler)

Definition at line 332 of file network.cpp.

◆ setError()

void TmwAthena::Network::setError ( const std::string &  error)
private

Definition at line 585 of file network.cpp.

◆ skip()

void TmwAthena::Network::skip ( int  len)

Definition at line 445 of file network.cpp.

◆ unregisterHandler()

void TmwAthena::Network::unregisterHandler ( MessageHandler handler)

Definition at line 340 of file network.cpp.

Friends And Related Symbol Documentation

◆ MessageOut

friend class MessageOut
friend

Definition at line 96 of file network.h.

◆ networkThread

int networkThread ( void *  data)
friend

Definition at line 234 of file network.cpp.

Member Data Documentation

◆ mError

std::string TmwAthena::Network::mError
private

Definition at line 117 of file network.h.

◆ mInBuffer

char* TmwAthena::Network::mInBuffer
private

Definition at line 110 of file network.h.

◆ mInSize

unsigned int TmwAthena::Network::mInSize = 0
private

Definition at line 111 of file network.h.

◆ mInstance

Network * TmwAthena::Network::mInstance = nullptr
staticprivate

Definition at line 125 of file network.h.

◆ mMessageHandlers

std::map<uint16_t, MessageHandler *> TmwAthena::Network::mMessageHandlers
private

Definition at line 123 of file network.h.

◆ mMutex

Mutex TmwAthena::Network::mMutex
private

Definition at line 120 of file network.h.

◆ mOutBuffer

char * TmwAthena::Network::mOutBuffer
private

Definition at line 110 of file network.h.

◆ mOutSize

unsigned int TmwAthena::Network::mOutSize = 0
private

Definition at line 112 of file network.h.

◆ mPacketInfo

std::unordered_map<uint16_t, const PacketInfo*> TmwAthena::Network::mPacketInfo
private

Definition at line 122 of file network.h.

◆ mServer

ServerInfo TmwAthena::Network::mServer
private

Definition at line 108 of file network.h.

◆ mSocket

TCPsocket TmwAthena::Network::mSocket = nullptr
private

Definition at line 106 of file network.h.

◆ mState

int TmwAthena::Network::mState = IDLE
private

Definition at line 116 of file network.h.

◆ mToSkip

unsigned int TmwAthena::Network::mToSkip = 0
private

Definition at line 114 of file network.h.

◆ mWorkerThread

SDL_Thread* TmwAthena::Network::mWorkerThread = nullptr
private

Definition at line 119 of file network.h.


The documentation for this class was generated from the following files: