ArClientSwitchManager Class Reference

#include <ArClientSwitchManager.h>

Inheritance diagram for ArClientSwitchManager:

ArASyncTask ArThread List of all members.

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.

Some program command line options can be used to configure this class:

ArClientSwitchManager options:
-centralServer <host>
-cs <host>
-centralServerPort <port>
-csp <port>
-identifier <identifier>
-id <identifier>
-centralServerInfoFile <fileName>
Examples:

serverDemo.cpp.


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).
bool getDebugLogging (void)
 Gets if this is using debug logging.
bool isConnected (void)
 Returns if we're connected or not.
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.
void netCentralServerHeartbeat (ArServerClient *client, ArNetPacket *packet)
 The handler for the packet that comes from the server so we know we're getting these.
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)
void setDebugLogging (bool debugLogging=false)
 Sets debug logging.
virtual ~ArClientSwitchManager ()

Protected Types

 CONNECTED
 If we're connected.
 CONNECTING
 If we're waiting for the response from the server.
 IDLE
 Don't want to connect.
 LOST_CONNECTION
 If we lost a connection... wait a bit and try again.
enum  State {
  IDLE, TRYING_CONNECTION, CONNECTING, CONNECTED,
  LOST_CONNECTION
}
 TRYING_CONNECTION
 If we're trying to connect.

Protected Member Functions

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

Protected Attributes

std::string myCentralServer
int myCentralServerPort
ArClientBasemyClient
ArMutex myDataMutex
bool myDebugLogging
ArFileParser myFileParser
ArRetFunctor1C< bool, ArClientSwitchManager,
ArArgumentBuilder * > 
myFilePasswordCB
ArRetFunctor1C< bool, ArClientSwitchManager,
ArArgumentBuilder * > 
myFileServerKeyCB
ArRetFunctor1C< bool, ArClientSwitchManager,
ArArgumentBuilder * > 
myFileUserCB
std::string myIdentifier
ArTime myLastConnectionAttempt
ArTime myLastTcpHeartbeat
ArTime myLastUdpHeartbeat
ArConstFunctorC< ArClientSwitchManagermyLogOptionsCB
ArFunctor2C< ArClientSwitchManager,
ArServerClient *, ArNetPacket * > 
myNetCentralHeartbeatCB
ArFunctor2C< ArClientSwitchManager,
ArServerClient *, ArNetPacket * > 
myNetCentralServerHeartbeatCB
ArRetFunctorC< bool, ArClientSwitchManagermyParseArgsCB
ArArgumentParsermyParser
std::string myPassword
ArRetFunctorC< bool, ArClientSwitchManagermyProcessFileCB
ArServerBasemyServer
double myServerBackupTimeout
ArServerClientmyServerClient
bool myServerHasHeartbeat
double myServerHeartbeatTimeout
std::string myServerKey
double myServerUdpHeartbeatTimeout
ArFunctorC< ArClientSwitchManagermySocketClosedCB
ArTime myStartedState
State myState
ArFunctor1C< ArClientSwitchManager,
ArNetPacket * > 
mySwitchCB
bool myTryConnection
std::string myUser


Member Enumeration Documentation

enum ArClientSwitchManager::State [protected]

Enumerator:
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.


Constructor & Destructor Documentation

ArClientSwitchManager::ArClientSwitchManager ( ArServerBase serverBase,
ArArgumentParser parser 
)

ArClientSwitchManager::~ArClientSwitchManager (  )  [virtual]


Member Function Documentation

void ArClientSwitchManager::clientSwitch ( ArNetPacket packet  ) 

The handler for the response to the switch command.

bool ArClientSwitchManager::filePasswordCallback ( ArArgumentBuilder arg  )  [protected]

bool ArClientSwitchManager::fileServerKeyCallback ( ArArgumentBuilder arg  )  [protected]

bool ArClientSwitchManager::fileUserCallback ( ArArgumentBuilder arg  )  [protected]

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).

bool ArClientSwitchManager::getDebugLogging ( void   )  [inline]

Gets if this is using debug logging.

bool ArClientSwitchManager::isConnected ( void   ) 

Returns if we're connected or not.

void ArClientSwitchManager::logOptions ( void   )  const

Log the options the simple connector has.

void ArClientSwitchManager::netCentralHeartbeat ( ArServerClient client,
ArNetPacket packet 
)

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

void ArClientSwitchManager::netCentralServerHeartbeat ( ArServerClient client,
ArNetPacket packet 
)

The handler for the packet that comes from the server so we know we're getting these.

bool ArClientSwitchManager::parseArgs ( void   ) 

Function to parse the arguments given in the constructor.

bool ArClientSwitchManager::parseFile ( const char *  fileName  ) 

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

bool ArClientSwitchManager::processFile ( void   )  [protected]

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

Implements ArASyncTask.

void ArClientSwitchManager::setDebugLogging ( bool  debugLogging = false  )  [inline]

Sets debug logging.

void ArClientSwitchManager::socketClosed ( void   )  [protected]

void ArClientSwitchManager::switchState ( State  state  )  [protected]


Member Data Documentation

std::string ArClientSwitchManager::myCentralServer [protected]

int ArClientSwitchManager::myCentralServerPort [protected]

ArClientBase* ArClientSwitchManager::myClient [protected]

ArMutex ArClientSwitchManager::myDataMutex [protected]

bool ArClientSwitchManager::myDebugLogging [protected]

ArFileParser ArClientSwitchManager::myFileParser [protected]

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

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

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

std::string ArClientSwitchManager::myIdentifier [protected]

ArTime ArClientSwitchManager::myLastConnectionAttempt [protected]

ArTime ArClientSwitchManager::myLastTcpHeartbeat [protected]

ArTime ArClientSwitchManager::myLastUdpHeartbeat [protected]

ArConstFunctorC<ArClientSwitchManager> ArClientSwitchManager::myLogOptionsCB [protected]

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

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

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

ArArgumentParser* ArClientSwitchManager::myParser [protected]

std::string ArClientSwitchManager::myPassword [protected]

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

ArServerBase* ArClientSwitchManager::myServer [protected]

double ArClientSwitchManager::myServerBackupTimeout [protected]

ArServerClient* ArClientSwitchManager::myServerClient [protected]

bool ArClientSwitchManager::myServerHasHeartbeat [protected]

double ArClientSwitchManager::myServerHeartbeatTimeout [protected]

std::string ArClientSwitchManager::myServerKey [protected]

double ArClientSwitchManager::myServerUdpHeartbeatTimeout [protected]

ArFunctorC<ArClientSwitchManager> ArClientSwitchManager::mySocketClosedCB [protected]

ArTime ArClientSwitchManager::myStartedState [protected]

State ArClientSwitchManager::myState [protected]

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

bool ArClientSwitchManager::myTryConnection [protected]

std::string ArClientSwitchManager::myUser [protected]


The documentation for this class was generated from the following files:
Generated on Fri Jul 31 12:37:29 2009 for ArNetworking by  doxygen 1.4.7