Network Class Reference

#include <network.h>

List of all members.


Detailed Description

Definition at line 40 of file network.h.


Public Types

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

Public Member Functions

 Network ()
 ~Network ()
bool connect (const std::string &address, short port)
void disconnect ()
void registerHandler (MessageHandler *handler)
void unregisterHandler (MessageHandler *handler)
void clearHandlers ()
int getState () const
const std::string & getError () const
bool isConnected () const
int getInSize () const
void skip (int len)
bool messageReady ()
MessageIn getNextMessage ()
void dispatchMessages ()
void flush ()

Private Types

typedef std::map< Uint16,
MessageHandler * > 
MessageHandlers
typedef MessageHandlers::iterator MessageHandlerIterator

Private Member Functions

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

Static Private Member Functions

static Networkinstance ()

Private Attributes

TCPsocket mSocket
std::string mAddress
short mPort
char * mInBuffer
char * mOutBuffer
unsigned int mInSize
unsigned int mOutSize
unsigned int mToSkip
int mState
std::string mError
SDL_Thread * mWorkerThread
SDL_mutex * mMutex
MessageHandlers mMessageHandlers

Static Private Attributes

static NetworkmInstance = 0

Friends

class MessageOut
int networkThread (void *data)

Member Typedef Documentation

typedef std::map<Uint16, MessageHandler*> Network::MessageHandlers [private]

Definition at line 114 of file network.h.

typedef MessageHandlers::iterator Network::MessageHandlerIterator [private]

Definition at line 115 of file network.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
IDLE 
CONNECTED 
CONNECTING 
DATA 
NET_ERROR 

Definition at line 79 of file network.h.


Constructor & Destructor Documentation

Network::Network (  ) 

Definition at line 96 of file network.cpp.

Network::~Network (  ) 

Definition at line 112 of file network.cpp.


Member Function Documentation

bool Network::connect ( const std::string &  address,
short  port 
)

Definition at line 128 of file network.cpp.

void Network::disconnect (  ) 

Definition at line 163 of file network.cpp.

void Network::registerHandler ( MessageHandler handler  ) 

Definition at line 180 of file network.cpp.

void Network::unregisterHandler ( MessageHandler handler  ) 

Definition at line 190 of file network.cpp.

void Network::clearHandlers (  ) 

Definition at line 200 of file network.cpp.

int Network::getState (  )  const [inline]

Definition at line 60 of file network.h.

const std::string& Network::getError (  )  const [inline]

Definition at line 62 of file network.h.

bool Network::isConnected (  )  const [inline]

Definition at line 64 of file network.h.

int Network::getInSize (  )  const [inline]

Definition at line 66 of file network.h.

void Network::skip ( int  len  ) 

Definition at line 246 of file network.cpp.

bool Network::messageReady (  ) 

Definition at line 270 of file network.cpp.

MessageIn Network::getNextMessage (  ) 

Definition at line 290 of file network.cpp.

void Network::dispatchMessages (  ) 

Definition at line 210 of file network.cpp.

void Network::flush (  ) 

Definition at line 227 of file network.cpp.

Network * Network::instance (  )  [static, private]

Definition at line 431 of file network.cpp.

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

Definition at line 436 of file network.cpp.

Uint16 Network::readWord ( int  pos  )  [private]

Definition at line 443 of file network.cpp.

bool Network::realConnect (  )  [private]

Definition at line 315 of file network.cpp.

void Network::receive (  )  [private]

Definition at line 345 of file network.cpp.


Friends And Related Function Documentation

friend class MessageOut [friend]

Definition at line 44 of file network.h.

int networkThread ( void *  data  )  [friend]

Definition at line 82 of file network.cpp.


Member Data Documentation

TCPsocket Network::mSocket [private]

Definition at line 98 of file network.h.

std::string Network::mAddress [private]

Definition at line 100 of file network.h.

short Network::mPort [private]

Definition at line 101 of file network.h.

char* Network::mInBuffer [private]

Definition at line 103 of file network.h.

char * Network::mOutBuffer [private]

Definition at line 103 of file network.h.

unsigned int Network::mInSize [private]

Definition at line 104 of file network.h.

unsigned int Network::mOutSize [private]

Definition at line 104 of file network.h.

unsigned int Network::mToSkip [private]

Definition at line 106 of file network.h.

int Network::mState [private]

Definition at line 108 of file network.h.

std::string Network::mError [private]

Definition at line 109 of file network.h.

SDL_Thread* Network::mWorkerThread [private]

Definition at line 111 of file network.h.

SDL_mutex* Network::mMutex [private]

Definition at line 112 of file network.h.

Definition at line 116 of file network.h.

Network * Network::mInstance = 0 [static, private]

Definition at line 118 of file network.h.


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

Generated on Sun Apr 26 17:30:43 2009 for The Mana World by  doxygen 1.5.5