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

ArServerBase Class Reference

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

#include <ArServerBase.h>

Inheritance diagram for ArServerBase:

ArASyncTask ArThread List of all members.

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.
 ArServerBase (bool addAriaExitCB=true, const char *serverName="")
 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)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketTcpWithExclusion (ArNetPacket *packet, const char *name, ArServerClient *excludeClient)
 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)
 Broadcasts packets to any client wanting this data.
bool broadcastPacketUdpWithExclusion (ArNetPacket *packet, const char *name, ArServerClient *excludeClient)
 Broadcasts packets to any client wanting this data.
void close (void)
 Closes the server.
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.
long getFrequency (unsigned int command, bool internalCall=false)
 Gets the frequncy a command is requested (mostly internal).
int getNumClients (void)
 Gets the number of clients connected.
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 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 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.
void 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).
bool open (unsigned int port, const char *openOnIP=NULL)
 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 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
void finishAcceptingSocket (ArSocket *socket, bool skipPassword=false, bool doNotReject=false)
 Internal function for server/client switching.

Protected Attributes

std::string myAdditionalDataFlags
ArFunctorC< ArServerBasemyAriaExitCB
std::list< ArFunctor1< ArServerClient * > * > myClientRemovedCallbacks
std::list< ArServerClient * > myClients
ArMutex myClientsMutex
std::list< ArFunctor * > myCycleCallbacks
ArMutex myCycleCallbacksMutex
std::map< unsigned int, ArServerData * > myDataMap
ArMutex myDataMutex
ArRetFunctor2C< long, ArServerBase,
unsigned int, bool > 
myGetFrequencyCB
std::map< std::string, std::string > myGroupDescription
 our mapping of the group names
unsigned int myNextDataNumber
bool myOpened
ArFunctor2C< ArServerBase,
ArNetPacket *, struct sockaddr_in * > 
myProcessPacketCB
int myRejecting
std::string myRejectingString
ArRetFunctor2C< bool, ArServerBase,
ArNetPacket *, struct sockaddr_in * > 
mySendUdpCB
std::string myServerKey
std::string myServerName
unsigned int myTcpPort
ArSocket myTcpSocket
unsigned int myUdpPort
ArNetPacketReceiverUdp myUdpReceiver
ArSocket myUdpSocket
const ArServerUserInfomyUserInfo

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

See also:
ArServerSimpleOpener

ArClientBase

ArServerMode

Examples:

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

Definition at line 91 of file ArServerBase.h.


Constructor & Destructor Documentation

ArServerBase::ArServerBase bool  addAriaExitCB = true,
const char *  serverName = ""
 

Constructor.

Definition at line 33 of file ArServerBase.cpp.

References Aria::addExitCallback(), myAriaExitCB, myNextDataNumber, myOpened, myProcessPacketCB, myRejecting, myServerName, myTcpPort, myUdpPort, myUdpReceiver, myUserInfo, ArFunctor::setName(), ArNetPacketReceiverUdp::setProcessPacketCB(), and ArThread::setThreadName().

ArServerBase::~ArServerBase  )  [virtual]
 

Destructor.

Definition at line 57 of file ArServerBase.cpp.

References close().


Member Function Documentation

void ArServerBase::acceptTcpSockets void   )  [protected]
 

accepts new sockets and moves them into the client list

Definition at line 150 of file ArServerBase.cpp.

References ArSocket::accept(), finishAcceptingSocket(), ArSocket::getFD(), ArMutex::lock(), myClientsMutex, myTcpSocket, and ArMutex::unlock().

Referenced by loopOnce().

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.

Definition at line 789 of file ArServerBase.cpp.

References ArMutex::lock(), myClientRemovedCallbacks, myDataMutex, and ArMutex::unlock().

Referenced by ArCentralForwarder::connectingCallOnce().

void ArServerBase::addCycleCallback ArFunctor functor  ) 
 

Add a callback to be called at every cycle.

Parameters:
functor Functor to add.

Definition at line 767 of file ArServerBase.cpp.

References ArMutex::lock(), myCycleCallbacks, myCycleCallbacksMutex, and ArMutex::unlock().

Referenced by ArServerHandlerPopup::ArServerHandlerPopup().

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

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

Definition at line 679 of file ArServerBase.cpp.

References addDataAdvanced().

Referenced by ArServerHandlerCommands::addCommand(), ArServerHandlerConfig::addDefaultServerCommands(), ArServerInfoDrawings::addDrawing(), ArServerMode::addModeData(), ArServerHandlerCommands::addStringCommand(), ArCentralManager::ArCentralManager(), ArClientSwitchManager::ArClientSwitchManager(), ArServerDeleteFileOnServer::ArServerDeleteFileOnServer(), ArServerFileFromClient::ArServerFileFromClient(), ArServerFileLister::ArServerFileLister(), ArServerFileToClient::ArServerFileToClient(), ArServerHandlerCommands::ArServerHandlerCommands(), ArServerHandlerConfig::ArServerHandlerConfig(), ArServerHandlerMap::ArServerHandlerMap(), ArServerHandlerMapping::ArServerHandlerMapping(), ArServerHandlerPopup::ArServerHandlerPopup(), ArServerInfoDrawings::ArServerInfoDrawings(), ArServerInfoRobot::ArServerInfoRobot(), ArServerInfoSensor::ArServerInfoSensor(), ArServerInfoStrings::ArServerInfoStrings(), ArServerMode::ArServerMode(), ArServerModeRatioDrive::ArServerModeRatioDrive(), and ArHybridForwarderVideo::finishConstructor().

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.

See also:
ArServerBase::addData for the rest of the parameters
Parameters:
commandNumber 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)

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

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

Definition at line 713 of file ArServerBase.cpp.

References ArServerData::addDataFlags(), ArMutex::lock(), ArLog::log(), myAdditionalDataFlags, myDataMap, myDataMutex, myGetFrequencyCB, myNextDataNumber, and ArMutex::unlock().

Referenced by addData(), and ArCentralForwarder::connectingCallOnce().

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

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

Definition at line 288 of file ArServerBase.cpp.

References broadcastPacketTcpWithExclusion().

Referenced by ArServerInfoStrings::addString(), ArServerHandlerCamera::cameraModeLookAtGoal(), ArServerHandlerCamera::cameraModeLookAtPoint(), ArServerHandlerCamera::cameraModePosition(), ArServerMode::checkBroadcastModeInfoPacket(), ArServerHandlerPopup::closePopup(), ArServerHandlerConfig::createEmptyConfigDefaults(), ArServerHandlerPopup::createPopup(), ArServerHandlerCommMonitor::cycleCallback(), ArServerHandlerCameraCollection::handleCameraCollectionModified(), ArServerFileFromClient::internalPutFile(), ArServerHandlerConfig::loadDefaultsFromFile(), ArServerHandlerConfig::loadDefaultsFromPacket(), ArServerHandlerMap::loadMap(), ArServerHandlerMap::mapChanged(), ArServerHandlerPopup::netPopupClicked(), ArCentralManager::runThread(), ArServerHandlerPopup::serverCycleCallback(), ArServerHandlerMapping::serverMappingEnd(), ArServerHandlerMapping::serverMappingStart(), ArServerHandlerCameraCollection::setParams(), and ArServerHandlerMap::useMap().

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

Definition at line 339 of file ArServerBase.cpp.

References broadcastPacketTcpByCommandWithExclusion().

Referenced by ArCentralForwarder::receiveData().

bool ArServerBase::broadcastPacketTcpByCommandWithExclusion ArNetPacket packet,
unsigned int  command,
ArServerClient excludeClient
 

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)
Returns:
false if there is no data for this name

Definition at line 355 of file ArServerBase.cpp.

References ArNetPacket::empty(), ArMutex::lock(), ArLog::log(), myClients, myClientsMutex, myOpened, ArNetPacket::setCommand(), and ArMutex::unlock().

Referenced by broadcastPacketTcpByCommand(), and broadcastPacketTcpWithExclusion().

bool ArServerBase::broadcastPacketTcpWithExclusion ArNetPacket packet,
const char *  name,
ArServerClient excludeClient
 

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)
Returns:
false if there is no data for this name

Definition at line 304 of file ArServerBase.cpp.

References broadcastPacketTcpByCommandWithExclusion(), ArMutex::lock(), ArLog::log(), myDataMap, myDataMutex, and ArMutex::unlock().

Referenced by broadcastPacketTcp(), and ArServerHandlerConfig::configUpdated().

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

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

Definition at line 398 of file ArServerBase.cpp.

References broadcastPacketUdpWithExclusion().

Referenced by ArServerHandlerCommMonitor::cycleCallback().

bool ArServerBase::broadcastPacketUdpByCommand 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 broadcastPacketUdpByCommandWithExclusion for that...

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

Definition at line 450 of file ArServerBase.cpp.

References broadcastPacketUdpByCommandWithExclusion().

Referenced by ArCentralForwarder::receiveData().

bool ArServerBase::broadcastPacketUdpByCommandWithExclusion ArNetPacket packet,
unsigned int  command,
ArServerClient excludeClient
 

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)
Returns:
false if there is no data for this name

Definition at line 466 of file ArServerBase.cpp.

References ArNetPacket::empty(), ArMutex::lock(), ArLog::log(), myClients, myClientsMutex, myOpened, ArNetPacket::setCommand(), and ArMutex::unlock().

Referenced by broadcastPacketUdpByCommand(), and broadcastPacketUdpWithExclusion().

bool ArServerBase::broadcastPacketUdpWithExclusion ArNetPacket packet,
const char *  name,
ArServerClient excludeClient
 

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)
Returns:
false if there is no data for this name

Definition at line 415 of file ArServerBase.cpp.

References broadcastPacketUdpByCommandWithExclusion(), ArMutex::lock(), ArLog::log(), myDataMap, myDataMutex, and ArMutex::unlock().

Referenced by broadcastPacketUdp().

void ArServerBase::close void   ) 
 

Closes the server.

Definition at line 115 of file ArServerBase.cpp.

References client, ArSocket::close(), ArMutex::lock(), ArLog::log(), myClients, myClientsMutex, myOpened, myTcpSocket, myUdpSocket, ArUtil::sleep(), and ArMutex::unlock().

Referenced by runThread(), ArCentralForwarder::~ArCentralForwarder(), and ~ArServerBase().

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

Returns if a command has a data flag.

Definition at line 1176 of file ArServerBase.cpp.

References dataHasFlagByCommand(), findCommandFromName(), and ArLog::log().

Referenced by ArCentralForwarder::connectingCallOnce().

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

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

Definition at line 1191 of file ArServerBase.cpp.

References ArMutex::lock(), myDataMap, myDataMutex, and ArMutex::unlock().

Referenced by dataHasFlag().

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

Definition at line 502 of file ArServerBase.cpp.

References ArMutex::lock(), ArLog::log(), myDataMap, myDataMutex, and ArMutex::unlock().

Referenced by dataHasFlag().

void ArServerBase::finishAcceptingSocket ArSocket socket,
bool  skipPassword = false,
bool  doNotReject = false
[protected]
 

Internal function for server/client switching.

Definition at line 174 of file ArServerBase.cpp.

References client, ArLog::log(), myClients, myDataMap, myRejecting, myRejectingString, mySendUdpCB, myServerKey, myUdpPort, myUserInfo, and ArMath::random().

Referenced by acceptTcpSockets(), and makeNewServerClientFromSocket().

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

Definition at line 1130 of file ArServerBase.cpp.

References ArMutex::lock(), myClients, myClientsMutex, and ArMutex::unlock().

int ArServerBase::getNumClients void   ) 
 

Gets the number of clients connected.

Definition at line 246 of file ArServerBase.cpp.

References ArMutex::lock(), myClients, myClientsMutex, and ArMutex::unlock().

unsigned int ArServerBase::getTcpPort void   ) 
 

Gets the tcp port we're using.

Definition at line 1207 of file ArServerBase.cpp.

References myTcpPort.

Referenced by ArCentralManager::runThread().

unsigned int ArServerBase::getUdpPort void   ) 
 

Gets the udp port we're using.

Definition at line 1212 of file ArServerBase.cpp.

References myUdpPort.

const ArServerUserInfo * ArServerBase::getUserInfo void   )  const
 

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

Definition at line 1107 of file ArServerBase.cpp.

References myUserInfo.

Referenced by ArCentralForwarder::connectingCallOnce().

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

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

Definition at line 808 of file ArServerBase.cpp.

References ArServerUserInfo::doNotUse(), ArMutex::lock(), ArLog::log(), myDataMutex, myServerName, myUserInfo, ArServerUserInfo::readFile(), ArServerUserInfo::setBaseDirectory(), and ArMutex::unlock().

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.

Definition at line 859 of file ArServerBase.cpp.

References logCommandGroupsToFile().

Referenced by ArServerSimpleOpener::checkAndLog().

void ArServerBase::logCommandGroupsToFile const char *  fileName  ) 
 

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

Definition at line 867 of file ArServerBase.cpp.

References file, ArMutex::lock(), ArLog::log(), myDataMap, myDataMutex, myGroupDescription, and ArMutex::unlock().

Referenced by logCommandGroups().

void ArServerBase::logGroupDescriptions void   ) 
 

Logs the command group names and descriptions.

Definition at line 1004 of file ArServerBase.cpp.

References logGroupDescriptionsToFile().

void ArServerBase::logGroupDescriptionsToFile const char *  fileName  ) 
 

Logs the command group names and descriptions to a file.

Definition at line 1012 of file ArServerBase.cpp.

References file, ArMutex::lock(), ArLog::log(), myDataMutex, myGroupDescription, and ArMutex::unlock().

Referenced by logGroupDescriptions().

void ArServerBase::logTracking bool  terse = true  ) 
 

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

Definition at line 1068 of file ArServerBase.cpp.

References ArSocket::getBytesRecvd(), ArSocket::getBytesSent(), ArSocket::getRecvs(), ArSocket::getSends(), ArMutex::lock(), ArLog::log(), myClients, myClientsMutex, myUdpSocket, and ArMutex::unlock().

Referenced by ArServerSimpleServerCommands::logTerseTracking(), and ArServerSimpleServerCommands::logVerboseTracking().

void ArServerBase::logUserInfo void   ) 
 

Logs the users and their groups.

Definition at line 842 of file ArServerBase.cpp.

References ArMutex::lock(), ArLog::log(), ArServerUserInfo::logUsers(), myDataMutex, myServerName, myUserInfo, and ArMutex::unlock().

Referenced by ArServerSimpleOpener::checkAndLog().

void ArServerBase::loopOnce void   ) 
 

Runs the server loop once.

Definition at line 531 of file ArServerBase.cpp.

References acceptTcpSockets(), client, ArMutex::lock(), myClientRemovedCallbacks, myClients, myCycleCallbacks, myCycleCallbacksMutex, myDataMutex, myOpened, myUdpReceiver, ArNetPacketReceiverUdp::readData(), and ArMutex::unlock().

Referenced by ArCentralForwarder::connectedCallOnce(), and runThread().

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

Definition at line 166 of file ArServerBase.cpp.

References finishAcceptingSocket(), ArMutex::lock(), myDataMutex, and ArMutex::unlock().

Referenced by ArClientSwitchManager::clientSwitch().

bool ArServerBase::open unsigned int  port,
const char *  openOnIP = NULL
 

Opens the server to accept new client connections.

Parameters:
port the port to open the server on
Returns:
true if the server could open the port, false otherwise

Definition at line 70 of file ArServerBase.cpp.

References ArSocket::close(), ArSocket::create(), ArSocket::findValidPort(), ArSocket::inPort(), ArMutex::lock(), ArLog::log(), myDataMutex, myOpened, myServerName, myTcpPort, myTcpSocket, myUdpPort, myUdpReceiver, myUdpSocket, ArSocket::netToHostOrder(), ArSocket::open(), ArSocket::setLinger(), ArSocket::setNonBlock(), ArNetPacketReceiverUdp::setSocket(), and ArMutex::unlock().

Referenced by ArCentralForwarder::connectingCallOnce(), and main().

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

Processes udp packets.

Definition at line 595 of file ArServerBase.cpp.

References client, ArMutex::lock(), myClients, myClientsMutex, ArClientBase::processPacket(), and ArMutex::unlock().

void ArServerBase::rejectSinceUsingCentralServer const char *  centralServerIPString  ) 
 

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

Definition at line 1059 of file ArServerBase.cpp.

References ArMutex::lock(), myDataMutex, myRejecting, myRejectingString, and ArMutex::unlock().

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.

Definition at line 800 of file ArServerBase.cpp.

References ArMutex::lock(), myClientRemovedCallbacks, myDataMutex, and ArMutex::unlock().

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.

Definition at line 778 of file ArServerBase.cpp.

References ArMutex::lock(), myCycleCallbacks, myCycleCallbacksMutex, and ArMutex::unlock().

void ArServerBase::resetTracking void   ) 
 

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

Definition at line 1093 of file ArServerBase.cpp.

References ArMutex::lock(), myClients, myClientsMutex, myDataMutex, myUdpSocket, ArSocket::resetTracking(), and ArMutex::unlock().

Referenced by ArServerSimpleServerCommands::resetTracking().

void ArServerBase::run void   )  [virtual]
 

Runs the server in this thread.

Reimplemented from ArASyncTask.

Definition at line 255 of file ArServerBase.cpp.

References ArASyncTask::runInThisThread().

Referenced by main().

void ArServerBase::runAsync void   )  [virtual]
 

Runs the server in its own thread.

Reimplemented from ArASyncTask.

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

Definition at line 260 of file ArServerBase.cpp.

References ArASyncTask::create().

Referenced by main().

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

Implements ArASyncTask.

Definition at line 265 of file ArServerBase.cpp.

References close(), loopOnce(), ArUtil::sleep(), and ArThread::threadStarted().

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

Sends Udp packets.

Definition at line 647 of file ArServerBase.cpp.

References myUdpSocket, and ArSocket::sendTo().

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.

Definition at line 1164 of file ArServerBase.cpp.

References ArMutex::lock(), myAdditionalDataFlags, myDataMutex, and ArMutex::unlock().

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

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

/// / =========================================================================///

Definition at line 984 of file ArServerBase.cpp.

References ArMutex::lock(), myDataMutex, myGroupDescription, and ArMutex::unlock().

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.

Definition at line 1043 of file ArServerBase.cpp.

References ArMutex::lock(), ArLog::log(), myDataMutex, myServerKey, and ArMutex::unlock().

void ArServerBase::setUserInfo const ArServerUserInfo userInfo  ) 
 

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

Definition at line 1112 of file ArServerBase.cpp.

References ArMutex::lock(), myDataMutex, myUserInfo, and ArMutex::unlock().

Referenced by ArCentralForwarder::connectingCallOnce().


Member Data Documentation

std::string ArServerBase::myAdditionalDataFlags [protected]
 

Definition at line 272 of file ArServerBase.h.

Referenced by addDataAdvanced(), and setAdditionalDataFlags().

ArFunctorC<ArServerBase> ArServerBase::myAriaExitCB [protected]
 

Definition at line 285 of file ArServerBase.h.

Referenced by ArServerBase().

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

Definition at line 281 of file ArServerBase.h.

Referenced by addClientRemovedCallback(), loopOnce(), and remClientRemovedCallback().

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

Definition at line 274 of file ArServerBase.h.

Referenced by broadcastPacketTcpByCommandWithExclusion(), broadcastPacketUdpByCommandWithExclusion(), close(), finishAcceptingSocket(), getFrequency(), getNumClients(), logTracking(), loopOnce(), processPacket(), and resetTracking().

ArMutex ArServerBase::myClientsMutex [protected]
 

Definition at line 252 of file ArServerBase.h.

Referenced by acceptTcpSockets(), broadcastPacketTcpByCommandWithExclusion(), broadcastPacketUdpByCommandWithExclusion(), close(), getFrequency(), getNumClients(), logTracking(), processPacket(), and resetTracking().

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

Definition at line 280 of file ArServerBase.h.

Referenced by addCycleCallback(), loopOnce(), and remCycleCallback().

ArMutex ArServerBase::myCycleCallbacksMutex [protected]
 

Definition at line 253 of file ArServerBase.h.

Referenced by addCycleCallback(), loopOnce(), and remCycleCallback().

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

Definition at line 264 of file ArServerBase.h.

Referenced by addDataAdvanced(), broadcastPacketTcpWithExclusion(), broadcastPacketUdpWithExclusion(), dataHasFlagByCommand(), findCommandFromName(), finishAcceptingSocket(), and logCommandGroupsToFile().

ArMutex ArServerBase::myDataMutex [protected]
 

Definition at line 251 of file ArServerBase.h.

Referenced by addClientRemovedCallback(), addDataAdvanced(), broadcastPacketTcpWithExclusion(), broadcastPacketUdpWithExclusion(), dataHasFlagByCommand(), findCommandFromName(), loadUserInfo(), logCommandGroupsToFile(), logGroupDescriptionsToFile(), logUserInfo(), loopOnce(), makeNewServerClientFromSocket(), open(), rejectSinceUsingCentralServer(), remClientRemovedCallback(), resetTracking(), setAdditionalDataFlags(), setGroupDescription(), setServerKey(), and setUserInfo().

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

Definition at line 286 of file ArServerBase.h.

Referenced by addDataAdvanced().

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

our mapping of the group names

Definition at line 266 of file ArServerBase.h.

Referenced by logCommandGroupsToFile(), logGroupDescriptionsToFile(), and setGroupDescription().

unsigned int ArServerBase::myNextDataNumber [protected]
 

Definition at line 271 of file ArServerBase.h.

Referenced by addDataAdvanced(), and ArServerBase().

bool ArServerBase::myOpened [protected]
 

Definition at line 273 of file ArServerBase.h.

Referenced by ArServerBase(), broadcastPacketTcpByCommandWithExclusion(), broadcastPacketUdpByCommandWithExclusion(), close(), loopOnce(), and open().

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

Definition at line 276 of file ArServerBase.h.

Referenced by ArServerBase().

int ArServerBase::myRejecting [protected]
 

Definition at line 268 of file ArServerBase.h.

Referenced by ArServerBase(), finishAcceptingSocket(), and rejectSinceUsingCentralServer().

std::string ArServerBase::myRejectingString [protected]
 

Definition at line 269 of file ArServerBase.h.

Referenced by finishAcceptingSocket(), and rejectSinceUsingCentralServer().

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

Definition at line 277 of file ArServerBase.h.

Referenced by finishAcceptingSocket().

std::string ArServerBase::myServerKey [protected]
 

Definition at line 284 of file ArServerBase.h.

Referenced by finishAcceptingSocket(), and setServerKey().

std::string ArServerBase::myServerName [protected]
 

Definition at line 250 of file ArServerBase.h.

Referenced by ArServerBase(), loadUserInfo(), logUserInfo(), and open().

unsigned int ArServerBase::myTcpPort [protected]
 

Definition at line 261 of file ArServerBase.h.

Referenced by ArServerBase(), getTcpPort(), and open().

ArSocket ArServerBase::myTcpSocket [protected]
 

Definition at line 278 of file ArServerBase.h.

Referenced by acceptTcpSockets(), close(), and open().

unsigned int ArServerBase::myUdpPort [protected]
 

Definition at line 262 of file ArServerBase.h.

Referenced by ArServerBase(), finishAcceptingSocket(), getUdpPort(), and open().

ArNetPacketReceiverUdp ArServerBase::myUdpReceiver [protected]
 

Definition at line 275 of file ArServerBase.h.

Referenced by ArServerBase(), loopOnce(), and open().

ArSocket ArServerBase::myUdpSocket [protected]
 

Definition at line 279 of file ArServerBase.h.

Referenced by close(), logTracking(), open(), resetTracking(), and sendUdp().

const ArServerUserInfo* ArServerBase::myUserInfo [protected]
 

Definition at line 283 of file ArServerBase.h.

Referenced by ArServerBase(), finishAcceptingSocket(), getUserInfo(), loadUserInfo(), logUserInfo(), and setUserInfo().


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