ArServerBase Class Reference

#include <ArServerBase.h>

Inheritance diagram for ArServerBase:

ArASyncTask ArThread List of all members.

Detailed Description

This class is the "base" server for network services.

Start this server by calling open(), and then running the loop with run() or runAsync(), (or loopOnce() if it is absolutely neccesary to use your own loop; see the implementation of run()). You can then pass this object to the various "ArServerInfo", "ArServerHandler", and ArServerMode classes.

Data request callbacks are added to an ArServerBase object by calling addData().

This class takes care of locking in its own function calls so you don't need to worry about locking and unlocking the class before you do things.

The counterpart of this class for clients is ArClientBase.

You can require user names and passwords for making connections to the server, so each user has a set of permissions for different command groups. To do this, load configuration from a userInfo file with loadUserInfo(). You can log the user info (and what commands users have) with logUserInfo(). You can log the command groups with logCommandGroups() or logCommandGroupsToFile(). For a description of the file see ArServerUserInfo. There is also an example in ArNetworking/examples/serverDemo.userInfo.

In addition to the user and password requirement you can set a server "key" (a special string of text) required (in addition to user and password) to access the server with setServerKey(), though this is ONLY used if user and password information is requied (so that older clients can connect if there's no user and password information required).

The way that the passwords are transmitted across the network is this: Upon connection the server sends a randomly generated (for that connection) string of text to the client which we'll call the passwordKey. The client then combines the serverKey (a string which must be known to connect to the server at all), the password, and the passwordKey (that string that is generated uniquely for each connection) and comes up with an md5 of that string and sends that md5 value across the line. The server then compares the md5 from the client with the md5 generated with the correct information on the server... if they match the password is good, otherwise it rejects the connection. This is NOT perfect security but should be much better then plaintext. If you care about perfect security then use an ssh tunnel with something like PUTTY from the machine the client is on to the machine the server is on with an openssh server set up (this'll likely even work in windows with cygwin) and set up a firewall on the machine the server is on that disallows port the server port connection from outside and only allows ssh from outside (and get a book or three and read those).

This class now handles identifiers for the ArServerClients... all server bases will let a client set a self identifier string, and a here goal... those may be used by any server. Messages can be sent to just server clients that match that message (so that its easier to send messages to people who sent commands).

Master servers (the main connection server base on the central server) can also give each connection an id number (with identGetConnectionID). Things that then connect to the other server bases on a master server (slave servers) should then set their ConnectionID (with identSetConnectionID) so that things can relate the different connections together.

See also:
ArServerSimpleOpener

ArClientBase

ArServerMode

Examples:

drawingsExample.cpp, drawingsExampleWithRobot.cpp, popupExample.cpp, serverDemo.cpp, and simpleServerExample.cpp.


Public Member Functions

void addClientRemovedCallback (ArFunctor1< ArServerClient * > *functor)
 Add a callback to be invoked when a client has been removed (but before it is deleted).
void addCycleCallback (ArFunctor *functor)
 Add a callback to be called at every cycle.
bool addData (const char *name, const char *description, ArFunctor2< ArServerClient *, ArNetPacket * > *functor, const char *argumentDescription, const char *returnDescription, const char *commandGroup=NULL, const char *dataFlags=NULL)
 Adds a callback to be called when requests for some data are recieved.
bool addDataAdvanced (const char *name, const char *description, ArFunctor2< ArServerClient *, ArNetPacket * > *functor, const char *argumentDescription, const char *returnDescription, const char *commandGroup=NULL, const char *dataFlags=NULL, unsigned int commandNumber=0, ArFunctor2< long, unsigned int > *requestChangedFunctor=NULL, ArFunctor2< ArServerClient *, ArNetPacket * > *requestOnceFunctor=NULL)
 Adds a callback for requests in a more advanced manner, for internal use.
bool addIdleSingleShotCallback (ArFunctor *functor)
 Adds an idle callback to be called once next time the robot is idle.
bool allowingIdlePackets (void)
 Gets if we're allowing idle packets.
 ArServerBase (bool addAriaExitCB=true, const char *serverName="", bool addBackupTimeoutToConfig=true, const char *backupTimeoutName="RobotToClientTimeoutInMins", const char *backupTimeoutDesc="The amount of time the central server can go without sending a packet to the robot successfully (when there are packets to send). A number less than 0 means this won't happen. The time is in minutes but takes doubles (ie .5) (5 seconds is used if the value is positive, but less than that amount)", bool masterServer=false, bool slaveServer=false, bool logPasswordFailureVerbosely=false, bool allowSlowPackets=true, bool allowIdlePackets=true)
 Constructor.
bool broadcastPacketTcp (ArNetPacket *packet, const char *name)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketTcpByCommand (ArNetPacket *packet, unsigned int command)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketTcpByCommandWithExclusion (ArNetPacket *packet, unsigned int command, ArServerClient *excludeClient, bool match=false, ArServerClientIdentifier identifier=ArServerClientIdentifier(), bool matchConnectionID=false)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketTcpToMatching (ArNetPacket *packet, const char *name, ArServerClientIdentifier identifier, bool matchConnectionID=false)
 Broadcasts packets to any client wanting this data that matches the ID.
bool broadcastPacketTcpWithExclusion (ArNetPacket *packet, const char *name, ArServerClient *excludeClient, bool match=false, ArServerClientIdentifier identifier=ArServerClientIdentifier(), bool matchConnectionID=false)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketUdp (ArNetPacket *packet, const char *name)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketUdpByCommand (ArNetPacket *packet, unsigned int command)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketUdpByCommandWithExclusion (ArNetPacket *packet, unsigned int command, ArServerClient *excludeClient, bool match=false, ArServerClientIdentifier identifier=ArServerClientIdentifier(), bool matchConnectionID=false)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketUdpToMatching (ArNetPacket *packet, const char *name, ArServerClientIdentifier identifier, bool matchConnectionID)
 Broadcasts packets to any client wanting this data that matches.
bool broadcastPacketUdpWithExclusion (ArNetPacket *packet, const char *name, ArServerClient *excludeClient, bool match=false, ArServerClientIdentifier identifier=ArServerClientIdentifier(), bool matchConnectionID=false)
 Broadcasts packets to any client wanting this data.
void close (void)
 Closes the server.
void closeConnectionID (ArTypes::UByte4 idNum)
 Closes connection with a given connection ID.
bool dataHasFlag (const char *name, const char *dataFlag)
 Returns if a command has a data flag.
bool dataHasFlagByCommand (unsigned int command, const char *dataFlag)
 Returns if a command has a data flag by command number.
unsigned int findCommandFromName (const char *command)
 Gets the number of a command.
bool getDebugLogging (void)
 Gets if this is using debug logging.
long getFrequency (unsigned int command, bool internalCall=false)
 Gets the frequncy a command is requested (mostly internal).
int getMostClients (void)
 Gets the most clients we've had connected.
int getNumClients (void)
 Gets the number of clients connected.
const char * getOpenOnIP (void)
 Gets the IP we're opening on (or NULL if there's none).
unsigned int getTcpPort (void)
 Gets the tcp port we're using.
unsigned int getUdpPort (void)
 Gets the udp port we're using.
const ArServerUserInfogetUserInfo (void) const
 Gets the user info we're using (mostly internal for switching).
bool hasIdleCallbacks (void)
 Internal, Sees if we have any idle callbacks we are waiting to process.
bool hasIdlePackets (void)
 Internal, Sees if we have any idle packets we are waiting to process.
bool hasSlowPackets (void)
 Internal, Sees if we have any slow packets we are waiting to process.
bool idleProcessingPending (void)
 Sees if we have any idle processing pending (idle packets or callbacks).
bool loadUserInfo (const char *fileName, const char *baseDirectory="")
 Loads up a set of usernames/passwords/permissions from a file.
void logCommandGroups (void)
 Logs the groups and commands in those groups.
void logCommandGroupsToFile (const char *fileName)
 Logs the groups and commands in those groups to a file.
void logConnections (const char *prefix="")
 Logs the connections.
void logGroupDescriptions (void)
 Logs the command group names and descriptions.
void logGroupDescriptionsToFile (const char *fileName)
 Logs the command group names and descriptions to a file.
void logTracking (bool terse=true)
 Logs the tracking on each client (how many packets and bytes were sent).
void logUserInfo (void)
 Logs the users and their groups.
void loopOnce (void)
 Runs the server loop once.
ArServerClientmakeNewServerClientFromSocket (ArSocket *socket, bool doNotReject)
 Makes a new serverclient from this socket (for switching, needs no password since this was an outgoing connection to a trusted server).
bool open (unsigned int port, const char *openOnIP=NULL, bool tcpOnly=false)
 Opens the server to accept new client connections.
void processPacket (ArNetPacket *packet, struct sockaddr_in *sin)
 Processes udp packets.
void rejectSinceUsingCentralServer (const char *centralServerIPString)
 Tells the server to reject connectings because we're usinga central server.
void remClientRemovedCallback (ArFunctor1< ArServerClient * > *functor)
 Remove the callback invoked when a client has been removed.
void remCycleCallback (ArFunctor *functor)
 Remove a callback to be called at every cycle.
void resetTracking (void)
 Clears the tracking on all the clients (resets counters).
virtual void run (void)
 Runs the server in this thread.
virtual void runAsync (void)
 Runs the server in its own thread.
virtual void * runThread (void *arg)
bool sendUdp (ArNetPacket *packet, struct sockaddr_in *sin)
 Sends Udp packets.
void setAdditionalDataFlags (const char *additionalDataFlags)
 Sets the data flags to add in addition to those passed in.
void setBackupTimeout (double timeoutInMins)
 Sets the backup timeout.
void setDebugLogging (bool debugLogging=false)
 Sets debug logging.
void setGroupDescription (const char *GrpName, const char *GrpDesc)
 Logs the command group names and command group descriptions for those names.
void setServerKey (const char *serverKey)
 Sets a 'key' needed to access the server through any account.
void setUserInfo (const ArServerUserInfo *userInfo)
 Sets the user info we'll use (mostly internal for switching).
virtual ~ArServerBase ()
 Destructor.

Protected Member Functions

void acceptTcpSockets (void)
 accepts new sockets and moves them into the client list
ArServerClientfinishAcceptingSocket (ArSocket *socket, bool skipPassword=false, bool doNotReject=false)
 Internal function for server/client switching.
void identGetConnectionID (ArServerClient *client, ArNetPacket *packet)
 The command get the ConnectionID of this server client connection.
void identSetConnectionID (ArServerClient *client, ArNetPacket *packet)
 The command set the ConnectionID of this server client connection.
void identSetHereGoal (ArServerClient *client, ArNetPacket *packet)
 The command set the here goal of this server client connection.
void identSetSelfIdentifier (ArServerClient *client, ArNetPacket *packet)
 The command set the self identifier of this server client connection.
void netIdleProcessingPending (ArServerClient *client, ArNetPacket *packet)
 callback for our slow idle thread, which is down below.
bool processFile (void)
void slowIdleCallback (void)

Protected Attributes

ArSocket myAcceptingSocket
std::string myAdditionalDataFlags
std::list< ArServerClient * > myAddList
ArMutex myAddListMutex
bool myAllowIdlePackets
bool myAllowSlowPackets
ArFunctorC< ArServerBasemyAriaExitCB
double myBackupTimeout
std::list< ArFunctor1< ArServerClient * > * > myClientRemovedCallbacks
std::list< ArServerClient * > myClients
ArMutex myClientsMutex
ArTypes::UByte4 myConnectionNumber
std::list< ArFunctor * > myCycleCallbacks
ArMutex myCycleCallbacksMutex
std::map< unsigned int, ArServerData * > myDataMap
ArMutex myDataMutex
bool myDebugLogging
ArRetFunctor2C< long, ArServerBase,
unsigned int, bool > 
myGetFrequencyCB
std::map< std::string, std::string > myGroupDescription
 our mapping of the group names
bool myHaveIdleCallbacks
bool myHaveIdlePackets
bool myHaveSlowPackets
ArFunctor2C< ArServerBase,
ArServerClient *, ArNetPacket * > 
myIdentGetConnectionIDCB
ArFunctor2C< ArServerBase,
ArServerClient *, ArNetPacket * > 
myIdentSetConnectionIDCB
ArFunctor2C< ArServerBase,
ArServerClient *, ArNetPacket * > 
myIdentSetHereGoalCB
ArFunctor2C< ArServerBase,
ArServerClient *, ArNetPacket * > 
myIdentSetSelfIdentifierCB
std::list< ArFunctor * > myIdleCallbacks
ArMutex myIdleCallbacksMutex
ArFunctor2C< ArServerBase,
ArServerClient *, ArNetPacket * > 
myIdleProcessingPendingCB
bool myLastIdleProcessingPending
bool myLogPasswordFailureVerbosely
std::string myLogPrefix
unsigned int myLoopMSecs
int myMostClients
unsigned int myNextDataNumber
int myNumClients
bool myOpened
std::string myOpenOnIP
ArRetFunctorC< bool, ArServerBasemyProcessFileCB
ArMutex myProcessingSlowIdleMutex
ArFunctor2C< ArServerBase,
ArNetPacket *, struct sockaddr_in * > 
myProcessPacketCB
int myRejecting
std::string myRejectingString
std::set< ArServerClient * > myRemoveSet
ArMutex myRemoveSetMutex
ArRetFunctor2C< bool, ArServerBase,
ArNetPacket *, struct sockaddr_in * > 
mySendUdpCB
std::string myServerKey
std::string myServerName
SlowIdleThreadmySlowIdleThread
bool myTcpOnly
unsigned int myTcpPort
ArSocket myTcpSocket
unsigned int myUdpPort
ArNetPacketReceiverUdp myUdpReceiver
ArSocket myUdpSocket
const ArServerUserInfomyUserInfo
ArLog::LogLevel myVerboseLogLevel

Friends

class ArServerBase::SlowIdleThread

Classes

class  SlowIdleThread


Constructor & Destructor Documentation

ArServerBase::ArServerBase ( bool  addAriaExitCB = true,
const char *  serverName = "",
bool  addBackupTimeoutToConfig = true,
const char *  backupTimeoutName = "RobotToClientTimeoutInMins",
const char *  backupTimeoutDesc = "The amount of time the central server can go without sending a packet to the robot successfully (when there are packets to send).  A number less than 0 means this won't happen.  The time is in minutes but takes doubles (ie .5) (5 seconds is used if the value is positive, but less than that amount)",
bool  masterServer = false,
bool  slaveServer = false,
bool  logPasswordFailureVerbosely = false,
bool  allowSlowPackets = true,
bool  allowIdlePackets = true 
)

Constructor.

Parameters:
addAriaExitCB whether to add an exit callback to aria or not
serverName the name for logging
addBackupTimeoutToConfig whether to add the backup timeout (to clients of this server) as a config option, if this is true it sets a default value for the timeout of 2 minutes, if its false it has no timeout (but you can set one,
See also:
ArServerBase::setBackupTimeout)
Parameters:
backupTimeoutName the name of backup timeout
backupTimeoutName the description of backup timeout
masterServer If this is a master server (ie a central manager)
slaveServer If this is a slave server (ie a central forwarder)
logPasswordFailureVerbosely Whether we log password failure verbosely or not
allowSlowPackets Whether we allow slow packets (that go in their own thread) or not... if we don't then they're processed in the main thread like they have always been
allowIdlePackets Whether we allow idle packets (that go in their own thread and are processed only when the robot is idle) or not... if we don't then they're processed in the main thread like they have always been

ArServerBase::~ArServerBase (  )  [virtual]

Destructor.


Member Function Documentation

void ArServerBase::acceptTcpSockets ( void   )  [protected]

accepts new sockets and moves them into the client list

void ArServerBase::addClientRemovedCallback ( ArFunctor1< ArServerClient * > *  functor  ) 

Add a callback to be invoked when a client has been removed (but before it is deleted).

Java Wrapper Library: Use ArFunctor_ServerClient instead of ArFunctor1<ArServerClient*> for functor.

void ArServerBase::addCycleCallback ( ArFunctor functor  ) 

Add a callback to be called at every cycle.

Parameters:
functor Functor to add.

bool ArServerBase::addData ( const char *  name,
const char *  description,
ArFunctor2< ArServerClient *, ArNetPacket * > *  functor,
const char *  argumentDescription,
const char *  returnDescription,
const char *  commandGroup = NULL,
const char *  dataFlags = NULL 
)

Adds a callback to be called when requests for some data are recieved.

Note:
A callback is called from the server run loop, and if this callback does not return in a timely manner data reception will be delayed (blocked).
Parameters:
name the name of the data
description the more verbose description of what the data is for
functor the functor to call when this data is requested
argumentDescription a description of the arguments expected
returnDescription a description of what the data returns
commandGroup the name of the group this command is in
dataFlags Most people won't need this, its for some advanced server things... this is a list of data flags separated by | characters, the flags are listed in ArClientData docs

Python Wrapper Library: Pass the name of a function or a lambda expression for

Java Wrapper Library: Use a subclass of ArFunctor_ServerData instead of the ArFunctor2 template

bool ArServerBase::addDataAdvanced ( const char *  name,
const char *  description,
ArFunctor2< ArServerClient *, ArNetPacket * > *  functor,
const char *  argumentDescription,
const char *  returnDescription,
const char *  commandGroup = NULL,
const char *  dataFlags = NULL,
unsigned int  advancedCommandNumber = 0,
ArFunctor2< long, unsigned int > *  requestChangedFunctor = NULL,
ArFunctor2< ArServerClient *, ArNetPacket * > *  requestOnceFunctor = NULL 
)

Adds a callback for requests in a more advanced manner, for internal use.

Parameters:
advancedCommandNumber 0 for most people... it is the optional number of the command, this is a very advanced option and is made for some server forwarding things so basically no one should use it, 0 means use the auto way... anything else does it manually... the number needs to be the same or higher as the next number available
requestChangedFunctor functor called with the lowest amount of time requested for this packet, called whenever the requests for the packet change, note that 0 and higher means thats how often it was asked for, -1 means something has requested the data but just when it is called, and -2 means that nothing wants the data
requestOnceFunctor functor called if this was a request once... with the server and client just like the normal functor, but its only called if its a request once, note that both are called (as long as they aren't NULL of course)
See also:
addData()

bool ArServerBase::addIdleSingleShotCallback ( ArFunctor functor  ) 

Adds an idle callback to be called once next time the robot is idle.

Returns:
true if the callback was added, false if not

bool ArServerBase::allowingIdlePackets ( void   ) 

Gets if we're allowing idle packets.

bool ArServerBase::broadcastPacketTcp ( ArNetPacket packet,
const char *  name 
)

Broadcasts packets to any client wanting this data.

... this no longer excludes things because that doesn't work well with the central server, so use broadcastPacketTcpWithExclusion for that if you really want it...

Parameters:
packet the packet to send
name the type of data to send
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketTcpByCommand ( ArNetPacket packet,
unsigned int  command 
)

Broadcasts packets to any client wanting this data.

... this no longer excludes things because that doesn't work well with the central server, so use broadcastPacketTcpByCommandWithExclusion for that...

Parameters:
packet the packet to send
command the command number of the data to send
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketTcpByCommandWithExclusion ( ArNetPacket packet,
unsigned int  command,
ArServerClient excludeClient,
bool  match = false,
ArServerClientIdentifier  identifier = ArServerClientIdentifier(),
bool  matchConnectionID = false 
)

Broadcasts packets to any client wanting this data.

Parameters:
packet the packet to send
command the command number of the data to send
excludeClient don't send data to this client (NULL (the default) just ignores this feature)
match whether to match the identifier or not
identifier the identifier to match
matchConnectionID true to match the connection ID, false to match the other ID
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketTcpToMatching ( ArNetPacket packet,
const char *  name,
ArServerClientIdentifier  identifier,
bool  matchConnectionID = false 
)

Broadcasts packets to any client wanting this data that matches the ID.

...

Parameters:
packet the packet to send
name the type of data to send
identifier the identifier to match
matchConnectionID true to match the connection ID, false to match the other ID
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketTcpWithExclusion ( ArNetPacket packet,
const char *  name,
ArServerClient excludeClient,
bool  match = false,
ArServerClientIdentifier  identifier = ArServerClientIdentifier(),
bool  matchConnectionID = false 
)

Broadcasts packets to any client wanting this data.

Parameters:
packet the packet to send
name the type of data to send
excludeClient don't send data to this client (NULL (the default) just ignores this feature)
match whether to match the identifier or not
identifier the identifier to match
matchConnectionID true to match the connection ID, false to match the other ID
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketUdp ( ArNetPacket packet,
const char *  name 
)

Broadcasts packets to any client wanting this data.

... this no longer excludes things because that doesn't work well with the central server, so use broadcastPacketUdpWithExclusion for that if you really want to

Parameters:
packet the packet to send
name the type of data to send
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketUdpByCommand ( ArNetPacket packet,
unsigned int  command 
)

Broadcasts packets to any client wanting this data.

...

(To restrict what clients the command is sent to, use the broadcastPacketUdpByCommandWithExclusion() method.)

Parameters:
packet the packet to send
command the type of data to send
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketUdpByCommandWithExclusion ( ArNetPacket packet,
unsigned int  command,
ArServerClient excludeClient,
bool  match = false,
ArServerClientIdentifier  identifier = ArServerClientIdentifier(),
bool  matchConnectionID = false 
)

Broadcasts packets to any client wanting this data.

Parameters:
packet the packet to send
command the type of data to send
excludeClient don't send data to this client (NULL (the default) just ignores this feature)
match whether to match the identifier or not
identifier the identifier to match
matchConnectionID true to match the connection ID, false to match the other ID
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketUdpToMatching ( ArNetPacket packet,
const char *  name,
ArServerClientIdentifier  identifier,
bool  matchConnectionID 
)

Broadcasts packets to any client wanting this data that matches.

...

Parameters:
packet the packet to send
name the type of data to send
identifier the identifier to match
matchConnectionID true to match the connection ID, false to match the other ID
Returns:
false if there is no data for this name

bool ArServerBase::broadcastPacketUdpWithExclusion ( ArNetPacket packet,
const char *  name,
ArServerClient excludeClient,
bool  match = false,
ArServerClientIdentifier  identifier = ArServerClientIdentifier(),
bool  matchConnectionID = false 
)

Broadcasts packets to any client wanting this data.

Parameters:
packet the packet to send
name the type of data to send
excludeClient don't send data to this client (NULL (the default) just ignores this feature)
match whether to match the identifier or not
identifier the identifier to match
matchConnectionID true to match the connection ID, false to match the other ID
Returns:
false if there is no data for this name

void ArServerBase::close ( void   ) 

Closes the server.

MPL adding this since it looks like its leaked

void ArServerBase::closeConnectionID ( ArTypes::UByte4  idNum  ) 

Closes connection with a given connection ID.

bool ArServerBase::dataHasFlag ( const char *  name,
const char *  dataFlag 
)

Returns if a command has a data flag.

bool ArServerBase::dataHasFlagByCommand ( unsigned int  command,
const char *  dataFlag 
)

Returns if a command has a data flag by command number.

unsigned int ArServerBase::findCommandFromName ( const char *  name  ) 

Gets the number of a command.

Parameters:
name Name is the name of the command number to be found
Returns:
the number of the command or 0 if no command has that name

ArServerClient * ArServerBase::finishAcceptingSocket ( ArSocket socket,
bool  skipPassword = false,
bool  doNotReject = false 
) [protected]

Internal function for server/client switching.

bool ArServerBase::getDebugLogging ( void   ) 

Gets if this is using debug logging.

long ArServerBase::getFrequency ( unsigned int  command,
bool  internalCall = false 
)

Gets the frequncy a command is requested (mostly internal).

Parameters:
command the command number, you can use findCommandFromName
internalCall whether its an internal call or not (whether to lock or not)
Returns:
returns lowest amount of time requested for this packet, note that 0 and higher means thats how often it was asked for, -1 means nothing requested the data at an interval but wants it when its been pushed, and -2 means that nothing wants the data

int ArServerBase::getMostClients ( void   ) 

Gets the most clients we've had connected.

int ArServerBase::getNumClients ( void   ) 

Gets the number of clients connected.

const char * ArServerBase::getOpenOnIP ( void   ) 

Gets the IP we're opening on (or NULL if there's none).

unsigned int ArServerBase::getTcpPort ( void   ) 

Gets the tcp port we're using.

unsigned int ArServerBase::getUdpPort ( void   ) 

Gets the udp port we're using.

const ArServerUserInfo * ArServerBase::getUserInfo ( void   )  const

Gets the user info we're using (mostly internal for switching).

bool ArServerBase::hasIdleCallbacks ( void   ) 

Internal, Sees if we have any idle callbacks we are waiting to process.

bool ArServerBase::hasIdlePackets ( void   ) 

Internal, Sees if we have any idle packets we are waiting to process.

bool ArServerBase::hasSlowPackets ( void   ) 

Internal, Sees if we have any slow packets we are waiting to process.

void ArServerBase::identGetConnectionID ( ArServerClient client,
ArNetPacket packet 
) [protected]

The command get the ConnectionID of this server client connection.

void ArServerBase::identSetConnectionID ( ArServerClient client,
ArNetPacket packet 
) [protected]

The command set the ConnectionID of this server client connection.

void ArServerBase::identSetHereGoal ( ArServerClient client,
ArNetPacket packet 
) [protected]

The command set the here goal of this server client connection.

void ArServerBase::identSetSelfIdentifier ( ArServerClient client,
ArNetPacket packet 
) [protected]

The command set the self identifier of this server client connection.

bool ArServerBase::idleProcessingPending ( void   ) 

Sees if we have any idle processing pending (idle packets or callbacks).

bool ArServerBase::loadUserInfo ( const char *  fileName,
const char *  baseDirectory = "" 
)

Loads up a set of usernames/passwords/permissions from a file.

void ArServerBase::logCommandGroups ( void   ) 

Logs the groups and commands in those groups.

It logs the command names first along with the list of commands in that group. Then it outputs a list of groups. Useful for building the user/pass file.

void ArServerBase::logCommandGroupsToFile ( const char *  fileName  ) 

Logs the groups and commands in those groups to a file.

void ArServerBase::logConnections ( const char *  prefix = ""  ) 

Logs the connections.

void ArServerBase::logGroupDescriptions ( void   ) 

Logs the command group names and descriptions.

void ArServerBase::logGroupDescriptionsToFile ( const char *  fileName  ) 

Logs the command group names and descriptions to a file.

void ArServerBase::logTracking ( bool  terse = true  ) 

Logs the tracking on each client (how many packets and bytes were sent).

void ArServerBase::logUserInfo ( void   ) 

Logs the users and their groups.

void ArServerBase::loopOnce ( void   ) 

Runs the server loop once.

ArServerClient * ArServerBase::makeNewServerClientFromSocket ( ArSocket socket,
bool  doNotReject 
)

Makes a new serverclient from this socket (for switching, needs no password since this was an outgoing connection to a trusted server).

void ArServerBase::netIdleProcessingPending ( ArServerClient client,
ArNetPacket packet 
) [protected]

callback for our slow idle thread, which is down below.

.. The command that returns if there is idle processing to do

bool ArServerBase::open ( unsigned int  port,
const char *  openOnIP = NULL,
bool  tcpOnly = false 
)

Opens the server to accept new client connections.

Parameters:
port the port to open the server on
openOnIP If not null, only listen on the local network interface with this address
tcpOnly If true, only accept TCP connections. If false, use both TCP and UDP communications with clients.
Returns:
true if the server could open the port, false otherwise

bool ArServerBase::processFile ( void   )  [protected]

void ArServerBase::processPacket ( ArNetPacket packet,
struct sockaddr_in *  sin 
)

Processes udp packets.

void ArServerBase::rejectSinceUsingCentralServer ( const char *  centralServerIPString  ) 

Tells the server to reject connectings because we're usinga central server.

void ArServerBase::remClientRemovedCallback ( ArFunctor1< ArServerClient * > *  functor  ) 

Remove the callback invoked when a client has been removed.

Java Wrapper Library: Use ArFunctor_ServerClient instead of ArFunctor1<ArServerClient*> for functor.

void ArServerBase::remCycleCallback ( ArFunctor functor  ) 

Remove a callback to be called at every cycle.

Parameters:
functor Functor to remove. If it's not currently in the cycle callback list, nothing is done.

void ArServerBase::resetTracking ( void   ) 

Clears the tracking on all the clients (resets counters).

void ArServerBase::run ( void   )  [virtual]

Runs the server in this thread.

Reimplemented from ArASyncTask.

void ArServerBase::runAsync ( void   )  [virtual]

Runs the server in its own thread.

Reimplemented from ArASyncTask.

Examples:
drawingsExample.cpp, drawingsExampleWithRobot.cpp, popupExample.cpp, serverDemo.cpp, and simpleServerExample.cpp.

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

Implements ArASyncTask.

bool ArServerBase::sendUdp ( ArNetPacket packet,
struct sockaddr_in *  sin 
)

Sends Udp packets.

void ArServerBase::setAdditionalDataFlags ( const char *  additionalDataFlags  ) 

Sets the data flags to add in addition to those passed in.

You can do multiple flags by separating them with a | character.

void ArServerBase::setBackupTimeout ( double  timeoutInMins  ) 

Sets the backup timeout.

Less than 0 means this won't happen. If this is positive but less than 5 seconds then 5 seconds is used.

void ArServerBase::setDebugLogging ( bool  debugLogging = false  ) 

Sets debug logging.

void ArServerBase::setGroupDescription ( const char *  cmdGrpName,
const char *  cmdGrpDesc 
)

Logs the command group names and command group descriptions for those names.

/// Notes: /// / Revision History: /// WHEN WHO WHAT and/or WHY /// 17-Nov-2005 NJ Created this function. /// / =========================================================================///

void ArServerBase::setServerKey ( const char *  serverKey  ) 

Sets a 'key' needed to access the server through any account.

.. this is NOT used if there is no user and password information.

void ArServerBase::setUserInfo ( const ArServerUserInfo userInfo  ) 

Sets the user info we'll use (mostly internal for switching).

void ArServerBase::slowIdleCallback ( void   )  [protected]


Friends And Related Function Documentation

friend class ArServerBase::SlowIdleThread [friend]


Member Data Documentation

ArSocket ArServerBase::myAcceptingSocket [protected]

std::string ArServerBase::myAdditionalDataFlags [protected]

std::list<ArServerClient *> ArServerBase::myAddList [protected]

ArMutex ArServerBase::myAddListMutex [protected]

bool ArServerBase::myAllowIdlePackets [protected]

bool ArServerBase::myAllowSlowPackets [protected]

ArFunctorC<ArServerBase> ArServerBase::myAriaExitCB [protected]

double ArServerBase::myBackupTimeout [protected]

std::list<ArFunctor1<ArServerClient *> *> ArServerBase::myClientRemovedCallbacks [protected]

std::list<ArServerClient *> ArServerBase::myClients [protected]

ArMutex ArServerBase::myClientsMutex [protected]

ArTypes::UByte4 ArServerBase::myConnectionNumber [protected]

std::list<ArFunctor*> ArServerBase::myCycleCallbacks [protected]

ArMutex ArServerBase::myCycleCallbacksMutex [protected]

std::map<unsigned int, ArServerData *> ArServerBase::myDataMap [protected]

ArMutex ArServerBase::myDataMutex [protected]

bool ArServerBase::myDebugLogging [protected]

ArRetFunctor2C<long, ArServerBase, unsigned int, bool> ArServerBase::myGetFrequencyCB [protected]

std::map<std::string, std::string> ArServerBase::myGroupDescription [protected]

our mapping of the group names

bool ArServerBase::myHaveIdleCallbacks [protected]

bool ArServerBase::myHaveIdlePackets [protected]

bool ArServerBase::myHaveSlowPackets [protected]

ArFunctor2C<ArServerBase, ArServerClient *, ArNetPacket *> ArServerBase::myIdentGetConnectionIDCB [protected]

ArFunctor2C<ArServerBase, ArServerClient *, ArNetPacket *> ArServerBase::myIdentSetConnectionIDCB [protected]

ArFunctor2C<ArServerBase, ArServerClient *, ArNetPacket *> ArServerBase::myIdentSetHereGoalCB [protected]

ArFunctor2C<ArServerBase, ArServerClient *, ArNetPacket *> ArServerBase::myIdentSetSelfIdentifierCB [protected]

std::list<ArFunctor *> ArServerBase::myIdleCallbacks [protected]

ArMutex ArServerBase::myIdleCallbacksMutex [protected]

ArFunctor2C<ArServerBase, ArServerClient *, ArNetPacket *> ArServerBase::myIdleProcessingPendingCB [protected]

bool ArServerBase::myLastIdleProcessingPending [protected]

bool ArServerBase::myLogPasswordFailureVerbosely [protected]

std::string ArServerBase::myLogPrefix [protected]

unsigned int ArServerBase::myLoopMSecs [protected]

int ArServerBase::myMostClients [protected]

unsigned int ArServerBase::myNextDataNumber [protected]

int ArServerBase::myNumClients [protected]

bool ArServerBase::myOpened [protected]

std::string ArServerBase::myOpenOnIP [protected]

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

ArMutex ArServerBase::myProcessingSlowIdleMutex [protected]

ArFunctor2C<ArServerBase, ArNetPacket *, struct sockaddr_in *> ArServerBase::myProcessPacketCB [protected]

int ArServerBase::myRejecting [protected]

std::string ArServerBase::myRejectingString [protected]

std::set<ArServerClient *> ArServerBase::myRemoveSet [protected]

ArMutex ArServerBase::myRemoveSetMutex [protected]

ArRetFunctor2C<bool, ArServerBase, ArNetPacket *, struct sockaddr_in *> ArServerBase::mySendUdpCB [protected]

std::string ArServerBase::myServerKey [protected]

std::string ArServerBase::myServerName [protected]

SlowIdleThread* ArServerBase::mySlowIdleThread [protected]

bool ArServerBase::myTcpOnly [protected]

unsigned int ArServerBase::myTcpPort [protected]

ArSocket ArServerBase::myTcpSocket [protected]

unsigned int ArServerBase::myUdpPort [protected]

ArNetPacketReceiverUdp ArServerBase::myUdpReceiver [protected]

ArSocket ArServerBase::myUdpSocket [protected]

const ArServerUserInfo* ArServerBase::myUserInfo [protected]

ArLog::LogLevel ArServerBase::myVerboseLogLevel [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