#include <ArNetServer.h>
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. | |
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) |
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 | 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 | 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 | |
ArFunctorC< ArNetServer > | myAriaExitCB |
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 |
ArRobot * | myRobot |
ArSocket | myServerSocket |
ArFunctor3C< ArNetServer, char **, int, ArSocket * > | myShutdownServerCB |
bool | mySquelchNormal |
ArFunctorC< ArNetServer > | myTaskCB |
bool | myWantToClose |
This class is for running a simple net 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.
Definition at line 55 of file ArNetServer.h.
|
Adds a new command. This adds a command to the list, when the command is given the broken up argv and argc are given along with the socket it came from (so that acks can occur) Definition at line 150 of file ArNetServer.cpp. References ArLog::log(). Referenced by ArNetServer(). |
|
Gets whether we are logging all data received or not.
Definition at line 255 of file ArNetServer.cpp. |
|
Gets whether we are logging all data sent or not.
Definition at line 237 of file ArNetServer.cpp. |
|
Initializes the server. Open the server, if you supply a robot this will run in the robots attached, if you do not supply a robot then it will be open and you'll have to call runOnce yourself (this is only recommended for advanced users)
Definition at line 96 of file ArNetServer.cpp. References ArSyncTask::addNewLeaf(), ArSyncTask::findNonRecursive(), ArSocket::getErrorStr(), ArRobot::getSyncTaskRoot(), ArLog::log(), ArSocket::open(), ArSocket::setLinger(), and ArSocket::setNonBlock(). |
|
Removes a command.
Definition at line 171 of file ArNetServer.cpp. Referenced by squelchNormal(). |
|
Sends the given string to all the clients. This sends the given string to all the clients, this string cannot be more than 2048 number of bytes Definition at line 201 of file ArNetServer.cpp. References sendToAllClientsPlain(). Referenced by close(), and internalShutdownServer(). |
|
Sets whether we are logging all data received or not.
Definition at line 246 of file ArNetServer.cpp. |
|
Sets whether we are logging all data sent or not.
Definition at line 223 of file ArNetServer.cpp. |