Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

ArClientSwitchManager Class Reference

The serverInfoFile takes the form of a config file roughly, there are 3 things you can put in it now. More...

#include <ArClientSwitchManager.h>

Inheritance diagram for ArClientSwitchManager:

ArASyncTask ArThread List of all members.

Public Member Functions

 ArClientSwitchManager (ArServerBase *serverBase, ArArgumentParser *parser)
void clientSwitch (ArNetPacket *packet)
 The handler for the response to the switch command.
const char * getCentralServerHostName (void)
 Gets the hostname we're using for the central server (NULL means we're not trying to sue the central server).
void logOptions (void) const
 Log the options the simple connector has.
void netCentralHeartbeat (ArServerClient *client, ArNetPacket *packet)
 The handler for the packet to let the server know we're still talking to it.
bool parseArgs (void)
 Function to parse the arguments given in the constructor.
bool parseFile (const char *fileName)
 Parses the file for holding the user, password, and server key.
virtual void * runThread (void *arg)
virtual ~ArClientSwitchManager ()

Protected Types

enum  State {
  IDLE, TRYING_CONNECTION, CONNECTING, CONNECTED,
  LOST_CONNECTION
}

Protected Member Functions

bool filePasswordCallback (ArArgumentBuilder *arg)
bool fileServerKeyCallback (ArArgumentBuilder *arg)
bool fileUserCallback (ArArgumentBuilder *arg)
void socketClosed (void)
void switchState (State state)

Protected Attributes

std::string myCentralServer
int myCentralServerPort
ArClientBasemyClient
ArMutex myDataMutex
ArFileParser myFileParser
ArRetFunctor1C< bool, ArClientSwitchManager,
ArArgumentBuilder * > 
myFilePasswordCB
ArRetFunctor1C< bool, ArClientSwitchManager,
ArArgumentBuilder * > 
myFileServerKeyCB
ArRetFunctor1C< bool, ArClientSwitchManager,
ArArgumentBuilder * > 
myFileUserCB
bool myGaveTimeWarning
std::string myIdentifier
ArConstFunctorC< ArClientSwitchManagermyLogOptionsCB
ArFunctor2C< ArClientSwitchManager,
ArServerClient *, ArNetPacket * > 
myNetCentralHeartbeatCB
ArRetFunctorC< bool, ArClientSwitchManagermyParseArgsCB
ArArgumentParsermyParser
std::string myPassword
ArServerBasemyServer
std::string myServerKey
ArFunctorC< ArClientSwitchManagermySocketClosedCB
ArTime myStartedState
State myState
ArFunctor1C< ArClientSwitchManager,
ArNetPacket * > 
mySwitchCB
bool myTryConnection
std::string myUser

Detailed Description

The serverInfoFile takes the form of a config file roughly, there are 3 things you can put in it now.

'user <user>', 'password <password>' and 'serverKey <serverkey>'. Note that it loads these files sequentially so if you pass it 5 files it'll read them in the order they were passed in. If you give it just the keyword but not the value (ie 'user') then it'll clear out that value.

Examples:

serverDemo.cpp.

Definition at line 41 of file ArClientSwitchManager.h.


Member Enumeration Documentation

enum ArClientSwitchManager::State [protected]
 

Enumeration values:
IDLE  Don't want to connect.
TRYING_CONNECTION  If we're trying to connect.
CONNECTING  If we're waiting for the response from the server.
CONNECTED  If we're connected.
LOST_CONNECTION  If we lost a connection... wait a bit and try again.

Definition at line 72 of file ArClientSwitchManager.h.


Constructor & Destructor Documentation

ArClientSwitchManager::ArClientSwitchManager ArServerBase serverBase,
ArArgumentParser parser
 

Definition at line 30 of file ArClientSwitchManager.cpp.

References ArServerBase::addData(), ArFileParser::addHandler(), Aria::addLogOptionsCB(), Aria::addParseArgsCB(), IDLE, myCentralServerPort, myClient, myFileParser, myFilePasswordCB, myFileServerKeyCB, myFileUserCB, myLogOptionsCB, myNetCentralHeartbeatCB, myParseArgsCB, myParser, myServer, mySwitchCB, ArFunctor::setName(), ArThread::setThreadName(), and switchState().

ArClientSwitchManager::~ArClientSwitchManager  )  [virtual]
 

Definition at line 71 of file ArClientSwitchManager.cpp.


Member Function Documentation

void ArClientSwitchManager::clientSwitch ArNetPacket packet  ) 
 

The handler for the response to the switch command.

Definition at line 163 of file ArClientSwitchManager.cpp.

References ArThread::cancel(), client, CONNECTED, ArClientBase::getTcpSocket(), ArMutex::lock(), ArLog::log(), ArServerBase::makeNewServerClientFromSocket(), myClient, myDataMutex, myServer, mySocketClosedCB, ArSocket::setCloseCallback(), switchState(), and ArMutex::unlock().

bool ArClientSwitchManager::filePasswordCallback ArArgumentBuilder arg  )  [protected]
 

Definition at line 316 of file ArClientSwitchManager.cpp.

References ArLog::log(), and myPassword.

bool ArClientSwitchManager::fileServerKeyCallback ArArgumentBuilder arg  )  [protected]
 

Definition at line 331 of file ArClientSwitchManager.cpp.

References ArLog::log(), and myServerKey.

bool ArClientSwitchManager::fileUserCallback ArArgumentBuilder arg  )  [protected]
 

Definition at line 300 of file ArClientSwitchManager.cpp.

References ArLog::log(), and myUser.

const char * ArClientSwitchManager::getCentralServerHostName void   ) 
 

Gets the hostname we're using for the central server (NULL means we're not trying to sue the central server).

Definition at line 346 of file ArClientSwitchManager.cpp.

References myCentralServer.

void ArClientSwitchManager::logOptions void   )  const
 

Log the options the simple connector has.

Definition at line 142 of file ArClientSwitchManager.cpp.

References ArLog::log().

void ArClientSwitchManager::netCentralHeartbeat ArServerClient client,
ArNetPacket packet
 

The handler for the packet to let the server know we're still talking to it.

Definition at line 278 of file ArClientSwitchManager.cpp.

References client, ArClientBase::sendPacketTcp(), and ArClientBase::sendPacketUdp().

bool ArClientSwitchManager::parseArgs void   ) 
 

Function to parse the arguments given in the constructor.

Definition at line 82 of file ArClientSwitchManager.cpp.

References ArArgumentParser::checkParameterArgumentInteger(), ArArgumentParser::checkParameterArgumentString(), ArMutex::lock(), myCentralServer, myCentralServerPort, myDataMutex, myIdentifier, myParser, myState, parseFile(), TRYING_CONNECTION, and ArMutex::unlock().

bool ArClientSwitchManager::parseFile const char *  fileName  ) 
 

Parses the file for holding the user, password, and server key.

Definition at line 286 of file ArClientSwitchManager.cpp.

References ArLog::log(), myFileParser, and ArFileParser::parseFile().

Referenced by parseArgs().

void * ArClientSwitchManager::runThread void *  arg  )  [virtual]
 

Implements ArASyncTask.

Definition at line 196 of file ArClientSwitchManager.cpp.

References ArClientBase::addHandler(), ArClientBase::blockingConnect(), CONNECTED, CONNECTING, ArClientBase::dataExists(), ArClientBase::disconnect(), ArThread::getRunning(), IDLE, ArMutex::lock(), ArLog::log(), LOST_CONNECTION, myCentralServer, myCentralServerPort, myClient, myDataMutex, myGaveTimeWarning, myIdentifier, myPassword, myServerKey, myStartedState, myState, mySwitchCB, myUser, ArClientBase::requestOnce(), ArClientBase::runAsync(), ArTime::secSince(), ArClientBase::setServerKey(), ArUtil::sleep(), ArBasePacket::strToBuf(), switchState(), ArThread::threadStarted(), TRYING_CONNECTION, ArMutex::unlock(), and ArClientBase::wasRejected().

void ArClientSwitchManager::socketClosed void   )  [protected]
 

Definition at line 185 of file ArClientSwitchManager.cpp.

References CONNECTED, ArMutex::lock(), ArLog::log(), LOST_CONNECTION, myDataMutex, myState, switchState(), and ArMutex::unlock().

void ArClientSwitchManager::switchState State  state  )  [protected]
 

Definition at line 75 of file ArClientSwitchManager.cpp.

References myGaveTimeWarning, myStartedState, myState, and ArTime::setToNow().

Referenced by ArClientSwitchManager(), clientSwitch(), runThread(), and socketClosed().


Member Data Documentation

std::string ArClientSwitchManager::myCentralServer [protected]
 

Definition at line 95 of file ArClientSwitchManager.h.

Referenced by getCentralServerHostName(), parseArgs(), and runThread().

int ArClientSwitchManager::myCentralServerPort [protected]
 

Definition at line 96 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager(), parseArgs(), and runThread().

ArClientBase* ArClientSwitchManager::myClient [protected]
 

Definition at line 89 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager(), clientSwitch(), and runThread().

ArMutex ArClientSwitchManager::myDataMutex [protected]
 

Definition at line 86 of file ArClientSwitchManager.h.

Referenced by clientSwitch(), parseArgs(), runThread(), and socketClosed().

ArFileParser ArClientSwitchManager::myFileParser [protected]
 

Definition at line 66 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager(), and parseFile().

ArRetFunctor1C<bool, ArClientSwitchManager, ArArgumentBuilder *> ArClientSwitchManager::myFilePasswordCB [protected]
 

Definition at line 108 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager().

ArRetFunctor1C<bool, ArClientSwitchManager, ArArgumentBuilder *> ArClientSwitchManager::myFileServerKeyCB [protected]
 

Definition at line 110 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager().

ArRetFunctor1C<bool, ArClientSwitchManager, ArArgumentBuilder *> ArClientSwitchManager::myFileUserCB [protected]
 

Definition at line 106 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager().

bool ArClientSwitchManager::myGaveTimeWarning [protected]
 

Definition at line 82 of file ArClientSwitchManager.h.

Referenced by runThread(), and switchState().

std::string ArClientSwitchManager::myIdentifier [protected]
 

Definition at line 97 of file ArClientSwitchManager.h.

Referenced by parseArgs(), and runThread().

ArConstFunctorC<ArClientSwitchManager> ArClientSwitchManager::myLogOptionsCB [protected]
 

Definition at line 100 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager().

ArFunctor2C<ArClientSwitchManager, ArServerClient *, ArNetPacket *> ArClientSwitchManager::myNetCentralHeartbeatCB [protected]
 

Definition at line 104 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager().

ArRetFunctorC<bool, ArClientSwitchManager> ArClientSwitchManager::myParseArgsCB [protected]
 

Definition at line 99 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager().

ArArgumentParser* ArClientSwitchManager::myParser [protected]
 

Definition at line 64 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager(), and parseArgs().

std::string ArClientSwitchManager::myPassword [protected]
 

Definition at line 92 of file ArClientSwitchManager.h.

Referenced by filePasswordCallback(), and runThread().

ArServerBase* ArClientSwitchManager::myServer [protected]
 

Definition at line 63 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager(), and clientSwitch().

std::string ArClientSwitchManager::myServerKey [protected]
 

Definition at line 93 of file ArClientSwitchManager.h.

Referenced by fileServerKeyCallback(), and runThread().

ArFunctorC<ArClientSwitchManager> ArClientSwitchManager::mySocketClosedCB [protected]
 

Definition at line 101 of file ArClientSwitchManager.h.

Referenced by clientSwitch().

ArTime ArClientSwitchManager::myStartedState [protected]
 

Definition at line 81 of file ArClientSwitchManager.h.

Referenced by runThread(), and switchState().

State ArClientSwitchManager::myState [protected]
 

Definition at line 80 of file ArClientSwitchManager.h.

Referenced by parseArgs(), runThread(), socketClosed(), and switchState().

ArFunctor1C<ArClientSwitchManager, ArNetPacket *> ArClientSwitchManager::mySwitchCB [protected]
 

Definition at line 102 of file ArClientSwitchManager.h.

Referenced by ArClientSwitchManager(), and runThread().

bool ArClientSwitchManager::myTryConnection [protected]
 

Definition at line 88 of file ArClientSwitchManager.h.

std::string ArClientSwitchManager::myUser [protected]
 

Definition at line 91 of file ArClientSwitchManager.h.

Referenced by fileUserCallback(), and runThread().


The documentation for this class was generated from the following files:
Generated on Tue Feb 20 10:51:51 2007 for ArNetworking by  doxygen 1.4.0