ArNetServer Class Reference

#include <ArNetServer.h>

List of all members.


Detailed Description

Class for running a simple net server to send/recv commands via text.

This class is for running a simple server which will have a list of commands to use and a fairly simple set of interactions... Start the server with the open function, add commands with the addCommand function and remove commands with remCommand, and close the server with the close function.

It has a built in mutex, if you only use sendToAllClients through the normal commands or during the robot loop you don't need to worry about locking anything and the server is locked before any of the callbacks for the commands are called so you really only need to lock the server if you're dealing with it from outside the way.


Public Member Functions

bool addCommand (const char *command, ArFunctor3< char **, int, ArSocket * > *functor, const char *help)
 Adds a new command.
 ArNetServer (bool addAriaExitCB=true)
 Constructor.
void close (void)
 Closes the server.
const char * getExtraString (void)
 Gets an extra string that the server holds for passing around.
bool getLoggingDataReceived (void)
 Gets whether we are logging all data received or not.
bool getLoggingDataSent (void)
 Gets whether we are logging all data sent or not.
bool getUseWrongEndChars (void)
 Gets whether we're using the wrong (legacy) end chars or not.
void internalAddSocketToDeleteList (ArSocket *socket)
 The internal function that adds a client to our delete list.
void internalAddSocketToList (ArSocket *socket)
 The internal function that adds a client to our list.
void internalEcho (char **argv, int argc, ArSocket *socket)
 The internal function for echo.
void internalGreeting (ArSocket *socket)
 the internal function that gives the greeting message
void internalHelp (char **argv, int argc, ArSocket *socket)
 The internal function for the help cb.
void internalHelp (ArSocket *socket)
 The internal function that does the help.
void internalQuit (char **argv, int argc, ArSocket *socket)
 The internal function for closing this connection.
void internalShutdownServer (char **argv, int argc, ArSocket *socket)
 The internal function for shutting down.
bool isOpen (void)
 Sees if the server is running and open.
int lock ()
 Lock the server.
bool open (ArRobot *robot, unsigned int port, const char *password, bool multipleClients=true, const char *openOnIP=NULL)
 Initializes the server.
void parseCommandOnSocket (ArArgumentBuilder *args, ArSocket *socket, bool allowLog=true)
 The internal function for parsing a command on a socket.
bool remCommand (const char *command)
 Removes a command.
void runOnce (void)
 the internal sync task we use for our loop
void sendToAllClients (const char *str,...)
 Sends the given string to all the clients.
void sendToAllClientsPlain (const char *str)
 Sends the given string to all the clients, no varargs, wrapper for java.
void sendToClient (ArSocket *socket, const char *ipString, const char *str,...)
 Sends the given string to the (hopefully) the client given (this method may go away).
void sendToClientPlain (ArSocket *socket, const char *ipString, const char *str)
 Sends the given plain string to the (hopefully) the client given (this method may go away).
void setExtraString (const char *str)
 Sets an extra string that the server holds for passing around.
void setLoggingDataReceived (bool loggingData)
 Sets whether we are logging all data received or not.
void setLoggingDataSent (bool loggingData)
 Sets whether we are logging all data sent or not.
void setUseWrongEndChars (bool useWrongEndChars)
 Sets whether we're using the wrong (legacy) end chars or not.
void squelchNormal (void)
 This squelchs all the normal commands and help.
int tryLock ()
 Try to lock the server without blocking.
int unlock ()
 Unlock the server.
 ~ArNetServer ()
 Destructor.

Protected Attributes

ArSocket myAcceptingSocket
ArFunctorC< ArNetServermyAriaExitCB
std::list< ArSocket * > myConnectingConns
std::list< ArSocket * > myConns
std::list< ArSocket * > myDeleteList
ArFunctor3C< ArNetServer,
char **, int, ArSocket * > 
myEchoCB
std::string myExtraString
std::map< std::string, ArFunctor3<
char **, int, ArSocket * > *,
ArStrCaseCmpOp
myFunctorMap
ArFunctor3C< ArNetServer,
char **, int, ArSocket * > 
myHelpCB
std::map< std::string, std::string,
ArStrCaseCmpOp
myHelpMap
bool myLoggingDataReceived
bool myLoggingDataSent
bool myMultipleClients
ArMutex myMutex
bool myOpened
std::string myPassword
unsigned int myPort
ArFunctor3C< ArNetServer,
char **, int, ArSocket * > 
myQuitCB
ArRobotmyRobot
ArSocket myServerSocket
ArFunctor3C< ArNetServer,
char **, int, ArSocket * > 
myShutdownServerCB
bool mySquelchNormal
ArFunctorC< ArNetServermyTaskCB
bool myUseWrongEndChars
bool myWantToClose


Member Function Documentation

void ArNetServer::sendToAllClients ( const char *  str,
  ... 
)

Sends the given string to all the clients.

Java and Python Wrappers: Not available in Java or Python wrapper libraries.

See also:
sendToAllClientsPlain()

void ArNetServer::sendToClient ( ArSocket socket,
const char *  ipString,
const char *  str,
  ... 
)

Sends the given string to the (hopefully) the client given (this method may go away).

Java and Python Wrappers: Not available in Java or Python wrapper libraries.

See also:
sendToClientPlain()


The documentation for this class was generated from the following file:
Generated on Thu Aug 6 09:39:36 2009 for Aria by  doxygen 1.5.1