#include <ArClientBase.h>
Inheritance diagram for ArClientBase:
Public Types | |
enum | { CLIENT_KEY_LENGTH = 16 } |
enum | ClientState { STATE_NO_CONNECTION, STATE_FAILED_CONNECTION, STATE_OPENED_SOCKET, STATE_EXCHANGED_INTROS, STATE_REJECTED, STATE_WAITING_LIST, STATE_CONNECTED, STATE_LOST_CONNECTION } |
The state of the connection. More... | |
Public Member Functions | |
void | addCycleCallback (ArFunctor *functor) |
Adds a functor to call every cycle. | |
void | addDisconnectOnErrorCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a call for when a disconnection has occured because of error. | |
bool | addHandler (const char *name, ArFunctor1< ArNetPacket * > *functor) |
Adds a functor for some particular data. | |
void | addServerShutdownCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a call for when the server shuts down. | |
ArClientBase () | |
Constructor. | |
bool | blockingConnect (const char *host, int port, bool print=true, const char *user=NULL, const char *password=NULL) |
Connect to a server. | |
bool | dataExists (const char *name) |
Sees if this data exists. | |
bool | disconnect (void) |
This method blocks while the connection is being shutdown. | |
unsigned int | findCommandFromName (const char *name) |
Returns the command number from the name. | |
void | finishNonBlockingDisconnect () |
This method should be used in conjunction with startNonBlockingDisconnect in threads that should not block (such as the main GUI thread). | |
void | getClientKey (unsigned char key[CLIENT_KEY_LENGTH]) |
Gets a (probably) unique key that can be used to identify the client (after connection). | |
int | getConnectTimeoutTime (void) |
Gets the time allowed for connection. | |
const std::map< unsigned int, ArClientData * > * | getDataMap (void) |
Internal function get get the data map. | |
const char * | getHost (void) |
Gets the name of the host we tried to connect to. | |
ArTime | getLastPacketReceived (void) |
Gets the last time a packet was received. | |
const char * | getName (unsigned int command, bool internalCall=false) |
Gets the name of the data a command is. | |
const char * | getName (ArNetPacket *packet, bool internalCall=false) |
Gets the name of the data a packet is for. | |
bool | getReceivedArgRetList (void) |
Gets if we received the list of arguments and. | |
bool | getReceivedDataList (void) |
Gets if we received the list of commands. | |
bool | getReceivedGroupAndFlagsList (void) |
Gets if we received the list of commands. | |
int | getRejected (void) |
Tells us the reason the connection was rejected (see ArServerCommands for details). | |
const char * | getRejectedString (void) |
Tells us the reason the connection was rejected (see ArServerCommands for details). | |
virtual const char * | getRobotName () const |
Returns the optional name of the connected robot for debugging purposes. | |
in_addr * | getTcpAddr (void) |
Internal function to get the socket (no one should need this). | |
ArSocket * | getTcpSocket (void) |
Internal function to get the tcp socket. | |
ArSocket * | getUdpSocket (void) |
Internal function to get the udp socket. | |
bool | internalBlockingConnect (const char *host, int port, bool print, const char *user, const char *password, ArSocket *tcpSocket) |
Internal function that'll do the connection (mainly for switch connections). | |
bool | isConnected (void) |
true if we're connected to a server | |
bool | isTcpOnlyFromServer (void) |
Returns whether we only get TCP data from the server not UDP. | |
bool | isTcpOnlyToServer (void) |
Returns whether we only send TCP data to the server. | |
void | logDataList (void) |
Print out or data with descriptions. | |
void | logTracking (bool terse) |
Logs the tracking information (packet and byte counts). | |
void | loopOnce (void) |
Run the loop once. | |
void | processPacket (ArNetPacket *packet, bool tcp) |
Process the packet wherever it came from. | |
void | processPacketUdp (ArNetPacket *packet, struct sockaddr_in *sin) |
Process a packet from udp (just hands off to processPacket). | |
void | remCycleCallback (ArFunctor *functor) |
Removes a functor called every cycle. | |
void | remDisconnectOnErrorCB (ArFunctor *functor) |
Removes a call for when a disconnection has occured because of error. | |
bool | remHandler (const char *name, ArFunctor1< ArNetPacket * > *functor) |
Removes a functor for some particular data by name. | |
void | remServerShutdownCB (ArFunctor *functor) |
Removes a call for when the server shuts down. | |
bool | request (const char *name, long mSec, ArNetPacket *packet=NULL) |
Request some data every mSec milliseconds. | |
bool | requestByCommand (unsigned int command, long mSec, ArNetPacket *packet=NULL) |
Request some data every mSec milliseconds by command not name. | |
bool | requestOnce (const char *name, ArNetPacket *packet=NULL, bool quiet=false) |
Request some data (or send a command) just once. | |
bool | requestOnceByCommand (unsigned int command, ArNetPacket *packet=NULL) |
Request some data (or send a command) just once by command not name. | |
bool | requestOnceByCommandUdp (unsigned int command, ArNetPacket *packet=NULL) |
Request some data (or send a command) just once by command not name. | |
bool | requestOnceUdp (const char *name, ArNetPacket *packet=NULL) |
Request some data (or send a command) just once by UDP. | |
bool | requestOnceWithString (const char *name, const char *str) |
Request some data (or send a command) just once with a string as argument. | |
bool | requestStop (const char *name) |
Don't want this data anymore. | |
bool | requestStopByCommand (unsigned int command) |
Don't want this data anymore, by command not name. | |
void | resetTracking (void) |
Clears the tracking information (resets counters). | |
virtual void | run (void) |
Runs the client in this thread. | |
virtual void | runAsync (void) |
Runs the client in its own thread. | |
virtual void * | runThread (void *arg) |
bool | sendPacketTcp (ArNetPacket *packet) |
Send a packet over TCP. | |
bool | sendPacketUdp (ArNetPacket *packet) |
Send a packet over UDP (unless client only wants tcp then sends over tcp). | |
void | setConnectTimeoutTime (int sec) |
Sets the time to allow for connection (default 3). | |
virtual void | setRobotName (const char *name) |
Sets the optional name of the connected robot for debugging purposes. | |
void | setServerKey (const char *serverKey, bool print=true) |
Sets the 'key' needed to connect to the server. | |
void | setTcpOnlyFromServer (void) |
Sets it so we only get TCP data from the server not UDP. | |
void | setTcpOnlyToServer (void) |
Sets it so we only send TCP data to the server. | |
bool | startNonBlockingDisconnect () |
This method should be called in threads that should not block (such as the main GUI thread). | |
bool | wasRejected (void) |
true if a server connection attempt failed because the server rejected the username or password, false if the connection failed for another reason, or the username/password were accepted. | |
virtual | ~ArClientBase () |
Destructor. | |
Protected Member Functions | |
void | buildList (ArNetPacket *packet) |
void | clear (void) |
bool | internalConnect (const char *host, int port, bool obsolete) |
void | internalStartUdp (void) |
void | internalSwitchState (ClientState state) |
bool | setupPacket (ArNetPacket *packet) |
void | trackPacketReceived (ArNetPacket *packet, bool tcp) |
void | trackPacketSent (ArNetPacket *packet, bool tcp) |
Protected Attributes | |
long | myAuthKey |
ArMutex | myCallbackMutex |
unsigned char | myClientKey [16] |
ArMutex | myClientMutex |
ArMutex | myCycleCallbackMutex |
std::list< ArFunctor * > | myCycleCallbacks |
ArMutex | myDataMutex |
std::list< ArFunctor * > | myDisconnectOnErrorCBList |
std::string | myHost |
std::map< unsigned int, ArClientData * > | myIntDataMap |
long | myIntroKey |
ArTime | myLastPacketReceived |
std::string | myLogPrefix |
Optional prefix to be inserted at the start of log messages. | |
ArMutex | myMapsMutex |
std::map< std::string, unsigned int > | myNameIntMap |
ArMutex | myPacketTrackingMutex |
std::string | myPassword |
ArFunctor2C< ArClientBase, ArNetPacket *, bool > | myProcessPacketCB |
ArFunctor2C< ArClientBase, ArNetPacket *, struct sockaddr_in * > | myProcessPacketUdpCB |
bool | myQuiet |
bool | myReceivedArgRetList |
bool | myReceivedDataList |
bool | myReceivedGroupAndFlagsList |
int | myRejected |
char | myRejectedString [32000] |
std::string | myRobotName |
Optional robot name for logging. | |
std::string | myServerKey |
unsigned int | myServerReportedUdpPort |
unsigned int | myServerSentUdpPort |
std::list< ArFunctor * > | myServerShutdownCBList |
ArTime | myStartedConnection |
ClientState | myState |
ArMutex | myStateMutex |
ArTime | myStateStarted |
bool | myTcpOnlyFrom |
bool | myTcpOnlyTo |
ArNetPacketReceiverTcp | myTcpReceiver |
ArNetPacketSenderTcp | myTcpSender |
ArSocket | myTcpSocket |
int | myTimeoutTime |
std::map< unsigned int, Tracker * > | myTrackingReceivedMap |
std::map< unsigned int, Tracker * > | myTrackingSentMap |
ArTime | myTrackingStarted |
bool | myUdpConfirmedFrom |
bool | myUdpConfirmedTo |
unsigned int | myUdpPort |
ArNetPacketReceiverUdp | myUdpReceiver |
sockaddr_in | myUdpSin |
bool | myUdpSinValid |
ArSocket | myUdpSocket |
std::string | myUser |
Classes | |
class | Tracker |
You need to connect a client to a server using blockingConnect() with the address for the server. Then you should add handlers to the client to receive information from the server (with addHandler(), request(), and requestOnce()). Then call run() or runAsync() (or loopOnce() if you really know what you're doing). You can also add a callback that will get called every cycle of the client.
User and password information may be required by the server. For details on that see ArServerBase. The most important thing is the modification to blockingConnect(), it can now take a user and password argument and upon failure you'll want to check wasRejected() to determine whether the client couldn't find the server or if the user and password were rejected. Another relevant function is setServerKey() to set the key (string of text) we need to connect to the server.
This class should be thread safe... The only thing you cannot do is call 'addHandler' or 'remHandler' from within a handler for that specific piece of data.
Definition at line 60 of file ArClientBase.h.
|
Definition at line 76 of file ArClientBase.h. |
|
The state of the connection.
Definition at line 65 of file ArClientBase.h. |
|
Constructor.
Definition at line 41 of file ArClientBase.cpp. References clear(), myProcessPacketCB, myProcessPacketUdpCB, myTcpReceiver, myTcpSender, myTcpSocket, myUdpReceiver, myUdpSocket, ArNetPacketReceiverUdp::setProcessPacketCB(), ArNetPacketReceiverTcp::setProcessPacketCB(), ArNetPacketReceiverUdp::setSocket(), ArNetPacketReceiverTcp::setSocket(), ArNetPacketSenderTcp::setSocket(), and ArThread::setThreadName(). |
|
Destructor.
Definition at line 57 of file ArClientBase.cpp. References clear(). |
|
Adds a functor to call every cycle. You cannot add a cycle callback from within a cycle or it will deadlock
Definition at line 120 of file ArClientBase.cpp. References ArMutex::lock(), myCycleCallbackMutex, myCycleCallbacks, and ArMutex::unlock(). Referenced by ArHybridForwarderVideo::finishConstructor(). |
|
Adds a call for when a disconnection has occured because of error.
Definition at line 1495 of file ArClientBase.cpp. References ArMutex::lock(), ArLog::log(), myCallbackMutex, myDisconnectOnErrorCBList, and ArMutex::unlock(). |
|
Adds a functor for some particular data. Note that if you try and add a handler for a specific piece of data from within a handler for that specific piece of data you'll deadlock.
Python Wrapper Library: Pass a function taking one argument for
Definition at line 1128 of file ArClientBase.cpp. References ArClientData::addFunctor(), ArClientData::getFunctorList(), ArMutex::lock(), ArClientData::lockFunctorList(), ArLog::log(), myIntDataMap, myMapsMutex, myNameIntMap, ArMutex::unlock(), and ArClientData::unlockFunctorList(). Referenced by ArClientDeleteFileOnServer::ArClientDeleteFileOnServer(), ArClientFileFromClient::ArClientFileFromClient(), ArClientFileLister::ArClientFileLister(), ArClientFileToClient::ArClientFileToClient(), ArCentralForwarder::connectingCallOnce(), ArHybridForwarderVideo::finishConstructor(), main(), OutputHandler::OutputHandler(), ArClientHandlerConfig::requestConfigFromServer(), and ArClientSwitchManager::runThread(). |
|
Adds a call for when the server shuts down.
Definition at line 1527 of file ArClientBase.cpp. References ArMutex::lock(), ArLog::log(), myCallbackMutex, myServerShutdownCBList, and ArMutex::unlock(). |
|
Connect to a server.
Definition at line 182 of file ArClientBase.cpp. References internalBlockingConnect(). Referenced by ArHybridForwarderVideo::ArHybridForwarderVideo(), ArClientSimpleConnector::connectClient(), main(), and ArClientSwitchManager::runThread(). |
|
Definition at line 893 of file ArClientBase.cpp. References ArClientData::addDataFlags(), getName(), ArLog::log(), myIntDataMap, myNameIntMap, myReceivedArgRetList, myReceivedDataList, myReceivedGroupAndFlagsList, ArClientData::setArgRetDescs(), and ArClientData::setCommandGroup(). Referenced by processPacket(). |
|
|
Sees if this data exists.
Definition at line 1448 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myNameIntMap, and ArMutex::unlock(). Referenced by ArClientHandlerConfig::canRequestDefaults(), ArHybridForwarderVideo::finishConstructor(), ArClientDeleteFileOnServer::isAvailable(), ArClientFileFromClient::isAvailable(), ArClientFileToClient::isAvailable(), ArClientFileLister::isAvailable(), ArClientFileFromClient::isAvailableFast(), ArClientFileFromClient::isAvailableSlow(), main(), ArClientFileFromClient::putFileToDirectory(), ArClientHandlerConfig::requestConfigFromServer(), ArClientSwitchManager::runThread(), and InputHandler::sendInput(). |
|
This method blocks while the connection is being shutdown.
Definition at line 446 of file ArClientBase.cpp. References finishNonBlockingDisconnect(), ArUtil::sleep(), and startNonBlockingDisconnect(). Referenced by gotConfig(), processPacket(), ArClientSwitchManager::runThread(), and ArCentralForwarder::~ArCentralForwarder(). |
|
Returns the command number from the name.
Definition at line 1217 of file ArClientBase.cpp. References ArMutex::lock(), ArLog::log(), myMapsMutex, myNameIntMap, and ArMutex::unlock(). Referenced by request(), requestOnce(), requestOnceUdp(), and requestStop(). |
|
This method should be used in conjunction with startNonBlockingDisconnect in threads that should not block (such as the main GUI thread).
Definition at line 472 of file ArClientBase.cpp. References ArSocket::close(), myState, myTcpSocket, myUdpSocket, and STATE_NO_CONNECTION. Referenced by disconnect(). |
|
Gets a (probably) unique key that can be used to identify the client (after connection).
|
|
Gets the time allowed for connection.
Definition at line 162 of file ArClientBase.cpp. References myTimeoutTime. |
|
Internal function get get the data map.
Definition at line 251 of file ArClientBase.h. References myIntDataMap. Referenced by ArCentralForwarder::connectingCallOnce(). |
|
Gets the name of the host we tried to connect to.
Definition at line 1637 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myHost, and ArMutex::unlock(). Referenced by main(). |
|
Gets the last time a packet was received.
Definition at line 1589 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myLastPacketReceived, and ArMutex::unlock(). |
|
Gets the name of the data a command is.
Definition at line 1604 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myIntDataMap, and ArMutex::unlock(). |
|
Gets the name of the data a packet is for.
Definition at line 1598 of file ArClientBase.cpp. Referenced by buildList(), logTracking(), ArCentralForwarder::receiveData(), ArCentralForwarder::requestChanged(), and ArCentralForwarder::requestOnce(). |
|
Gets if we received the list of arguments and.
Definition at line 270 of file ArClientBase.h. References myReceivedArgRetList. Referenced by ArCentralForwarder::connectingCallOnce(). |
|
Gets if we received the list of commands.
Definition at line 268 of file ArClientBase.h. References myReceivedDataList. Referenced by ArCentralForwarder::connectingCallOnce(). |
|
Gets if we received the list of commands.
Definition at line 272 of file ArClientBase.h. References myReceivedGroupAndFlagsList. Referenced by ArCentralForwarder::connectingCallOnce(). |
|
Tells us the reason the connection was rejected (see ArServerCommands for details).
Definition at line 274 of file ArClientBase.h. References myRejected. |
|
Tells us the reason the connection was rejected (see ArServerCommands for details).
Definition at line 276 of file ArClientBase.h. References myRejectedString. |
|
Returns the optional name of the connected robot for debugging purposes.
Definition at line 77 of file ArClientBase.cpp. References myRobotName. |
|
Internal function to get the socket (no one should need this).
Definition at line 241 of file ArClientBase.h. References ArSocket::inAddr(), and myTcpSocket. |
|
Internal function to get the tcp socket.
Definition at line 247 of file ArClientBase.h. References myTcpSocket. Referenced by ArClientSwitchManager::clientSwitch(), ArCentralManager::netClientList(), ArCentralManager::netServerSwitch(), and ArCentralManager::runThread(). |
|
Internal function to get the udp socket.
Definition at line 249 of file ArClientBase.h. References myUdpSocket. |
|
Internal function that'll do the connection (mainly for switch connections).
Definition at line 189 of file ArClientBase.cpp. References clear(), ArSocket::close(), ArNetPacket::empty(), internalConnect(), internalStartUdp(), internalSwitchState(), ArMutex::lock(), ArLog::log(), loopOnce(), ArTime::mSecSince(), myDataMutex, myHost, myPassword, myQuiet, myStartedConnection, myState, myTcpOnlyFrom, myTcpOnlyTo, myTcpReceiver, myTcpSocket, myTimeoutTime, myUdpConfirmedFrom, myUdpConfirmedTo, myUdpSocket, myUser, sendPacketTcp(), ArNetPacket::setCommand(), ArNetPacketReceiverTcp::setQuiet(), ArTime::setToNow(), ArUtil::sleep(), STATE_CONNECTED, STATE_FAILED_CONNECTION, STATE_LOST_CONNECTION, STATE_NO_CONNECTION, STATE_OPENED_SOCKET, STATE_REJECTED, ArSocket::transfer(), and ArMutex::unlock(). Referenced by blockingConnect(), and ArCentralForwarder::startingCallOnce(). |
|
Definition at line 382 of file ArClientBase.cpp. References ArSocket::connect(), internalStartUdp(), internalSwitchState(), ArLog::log(), myQuiet, myTcpSocket, myUdpPort, ArSocket::setNonBlock(), STATE_FAILED_CONNECTION, and STATE_OPENED_SOCKET. Referenced by internalBlockingConnect(). |
|
Definition at line 424 of file ArClientBase.cpp. References ArSocket::create(), ArSocket::findValidPort(), ArSocket::inAddr(), ArSocket::inPort(), ArLog::log(), myQuiet, myTcpOnlyFrom, myTcpOnlyTo, myTcpSocket, myUdpPort, myUdpSin, myUdpSinValid, myUdpSocket, ArSocket::netToHostOrder(), ArSocket::setLinger(), and ArSocket::setNonBlock(). Referenced by internalBlockingConnect(), and internalConnect(). |
|
Definition at line 1104 of file ArClientBase.cpp. References myState, myStateStarted, and ArTime::setToNow(). Referenced by clear(), internalBlockingConnect(), internalConnect(), loopOnce(), and processPacket(). |
|
true if we're connected to a server
Definition at line 122 of file ArClientBase.h. References myState, and STATE_CONNECTED. Referenced by ArCentralForwarder::connectedCallOnce(), ArHybridForwarderVideo::finishConstructor(), and ArCentralForwarder::~ArCentralForwarder(). |
|
Returns whether we only get TCP data from the server not UDP.
Definition at line 1570 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myTcpOnlyFrom, and ArMutex::unlock(). |
|
Returns whether we only send TCP data to the server.
Definition at line 1579 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myTcpOnlyTo, and ArMutex::unlock(). |
|
Print out or data with descriptions.
Definition at line 1457 of file ArClientBase.cpp. References ArClientData::getArgumentDescription(), ArClientData::getCommand(), ArClientData::getCommandGroup(), ArClientData::getDataFlagsString(), ArClientData::getDescription(), ArClientData::getFunctorList(), ArClientData::getName(), ArClientData::getReturnDescription(), ArMutex::lock(), ArLog::log(), myDataMutex, myIntDataMap, and ArMutex::unlock(). Referenced by ArClientSimpleConnector::connectClient(), InputHandler::listData(), and main(). |
|
Logs the tracking information (packet and byte counts).
Definition at line 1688 of file ArClientBase.cpp. References ArSocket::getBytesRecvd(), ArSocket::getBytesSent(), getName(), ArSocket::getRecvs(), ArSocket::getSends(), ArMutex::lock(), ArLog::log(), ArClientBase::Tracker::myBytesTcp, ArClientBase::Tracker::myBytesUdp, myDataMutex, ArClientBase::Tracker::myPacketsTcp, ArClientBase::Tracker::myPacketsUdp, myPacketTrackingMutex, myTcpSocket, myTrackingReceivedMap, myTrackingSentMap, myTrackingStarted, myUdpSocket, ArTime::secSince(), and ArMutex::unlock(). Referenced by InputHandler::logTrackingTerse(), and InputHandler::logTrackingVerbose(). |
|
|
|
Process a packet from udp (just hands off to processPacket).
Definition at line 1032 of file ArClientBase.cpp. References ArNetPacket::empty(), ArMutex::lock(), ArLog::log(), myDataMutex, myIntroKey, myLastPacketReceived, myQuiet, myServerReportedUdpPort, myState, myUdpConfirmedFrom, myUdpSin, processPacket(), sendPacketTcp(), ArNetPacket::setCommand(), ArTime::setToNow(), STATE_CONNECTED, STATE_EXCHANGED_INTROS, STATE_WAITING_LIST, and ArMutex::unlock(). |
|
Removes a functor called every cycle.
Definition at line 134 of file ArClientBase.cpp. References ArMutex::lock(), myCycleCallbackMutex, myCycleCallbacks, and ArMutex::unlock(). |
|
Removes a call for when a disconnection has occured because of error.
Definition at line 1513 of file ArClientBase.cpp. References ArMutex::lock(), myCallbackMutex, myDisconnectOnErrorCBList, and ArMutex::unlock(). |
|
Removes a functor for some particular data by name. Note that if you try and remove a handler for a specific piece of data from within a handler for that specific piece of data you'll deadlock.
Definition at line 1184 of file ArClientBase.cpp. References ArMutex::lock(), ArClientData::lockFunctorList(), ArLog::log(), myIntDataMap, myMapsMutex, myNameIntMap, ArClientData::remFunctor(), ArMutex::unlock(), and ArClientData::unlockFunctorList(). Referenced by ArClientHandlerConfig::requestConfigFromServer(). |
|
Removes a call for when the server shuts down.
Definition at line 1545 of file ArClientBase.cpp. References ArMutex::lock(), myCallbackMutex, myServerShutdownCBList, and ArMutex::unlock(). |
|
Request some data every mSec milliseconds.
Definition at line 1250 of file ArClientBase.cpp. References findCommandFromName(), ArLog::log(), myLogPrefix, and requestByCommand(). Referenced by ArCentralForwarder::connectingCallOnce(), main(), and OutputHandler::OutputHandler(). |
|
Request some data every mSec milliseconds by command not name.
Definition at line 1273 of file ArClientBase.cpp. References ArBasePacket::byte4ToBuf(), ArBasePacket::dataToBuf(), ArNetPacket::resetRead(), sendPacketTcp(), ArNetPacket::setCommand(), and ArBasePacket::uByte2ToBuf(). Referenced by request(), and ArCentralForwarder::requestChanged(). |
|
|
Request some data (or send a command) just once by command not name. this is useful for things like video data that you don't want to clog up the bandwidth with... its also useful for things like sending commands
Definition at line 1364 of file ArClientBase.cpp. References sendPacketTcp(), and ArNetPacket::setCommand(). Referenced by ArCentralForwarder::requestChanged(), requestOnce(), and ArCentralForwarder::requestOnce(). |
|
Request some data (or send a command) just once by command not name. this is useful for things like video data that you don't want to clog up the bandwidth with... its also useful for things like sending commands
Definition at line 1389 of file ArClientBase.cpp. References myTcpOnlyTo, sendPacketTcp(), sendPacketUdp(), and ArNetPacket::setCommand(). Referenced by requestOnceUdp(). |
|
Request some data (or send a command) just once by UDP. this is useful for things like video data that you don't want to clog up the bandwidth with... its also useful for things like sending commands... Note that this version goes over UDP. This means you CANNOT assume it will get there or that you will get a response...
Definition at line 1346 of file ArClientBase.cpp. References findCommandFromName(), ArLog::log(), myLogPrefix, and requestOnceByCommandUdp(). |
|
Request some data (or send a command) just once with a string as argument. this is useful for things like video data that you don't want to clog up the bandwidth with... its also useful for things like sending commands
Definition at line 1420 of file ArClientBase.cpp. References ArMutex::lock(), ArLog::log(), myDataMutex, myLogPrefix, myNameIntMap, sendPacketTcp(), ArNetPacket::setCommand(), ArBasePacket::strToBuf(), and ArMutex::unlock(). Referenced by ArClientFileLister::changeToAbsDir(), ArClientFileLister::changeToDir(), ArClientFileLister::changeToTopDir(), ArClientHandlerConfig::requestSectionDefaults(), and ArClientFileLister::upOneDir(). |
|
Don't want this data anymore.
Definition at line 1294 of file ArClientBase.cpp. References findCommandFromName(), ArLog::log(), myLogPrefix, and requestStopByCommand(). Referenced by OutputHandler::~OutputHandler(). |
|
Don't want this data anymore, by command not name.
Definition at line 1305 of file ArClientBase.cpp. References sendPacketTcp(), ArNetPacket::setCommand(), and ArBasePacket::uByte2ToBuf(). Referenced by ArCentralForwarder::requestChanged(), and requestStop(). |
|
Clears the tracking information (resets counters).
Definition at line 1867 of file ArClientBase.cpp. References ArMutex::lock(), myPacketTrackingMutex, myTcpSocket, myTrackingReceivedMap, myTrackingSentMap, myTrackingStarted, myUdpSocket, ArSocket::resetTracking(), ArTime::setToNow(), and ArMutex::unlock(). Referenced by clear(), and InputHandler::resetTracking(). |
|
Runs the client in this thread.
Reimplemented from ArASyncTask.
Definition at line 579 of file ArClientBase.cpp. References ArASyncTask::runInThisThread(). Referenced by main(). |
|
Runs the client in its own thread.
Reimplemented from ArASyncTask. Definition at line 584 of file ArClientBase.cpp. References ArASyncTask::create(). Referenced by ArHybridForwarderVideo::ArHybridForwarderVideo(), main(), and ArClientSwitchManager::runThread(). |
|
Implements ArASyncTask. Definition at line 589 of file ArClientBase.cpp. References loopOnce(), ArUtil::sleep(), and ArThread::threadStarted(). |
|
Send a packet over TCP.
Definition at line 490 of file ArClientBase.cpp. References myTcpSender, ArNetPacketSenderTcp::sendPacket(), setupPacket(), and trackPacketSent(). Referenced by ArServerInfoRobot::activityTimeInfo(), ArServerInfoRobot::batteryInfo(), ArServerDeleteFileOnServer::deleteFile(), ArServerHandlerCameraCollection::getCameraList(), ArServerHandlerConfig::getConfigDefaults(), ArServerHandlerConfig::getConfigSectionFlags(), ArServerFileLister::getDirListing(), ArServerFileToClient::getFile(), ArServerMode::getModeDataList(), ArServerMode::getModeInfo(), ArServerHandlerCommMonitor::handleAckCommTcp(), ArServerHandlerCamera::handleCameraModeUpdated(), ArServerHandlerCamera::handleGetCameraModeList(), ArServerHandlerConfig::handleGetConfig(), ArServerHandlerCommMonitor::handleGetHeartbeatInterval(), internalBlockingConnect(), ArServerFileFromClient::internalPutFile(), ArServerHandlerConfig::internalSetConfig(), ArClientSwitchManager::netCentralHeartbeat(), ArCentralManager::netClientList(), ArServerInfoDrawings::netGetDrawingList(), ArServerInfoStrings::netGetStrings(), ArServerInfoStrings::netGetStringsInfo(), ArServerHandlerCommands::netListCommands(), ArServerInfoDrawings::netListDrawings(), ArServerHandlerCommands::netListStringCommands(), ArCentralManager::netServerSwitch(), ArServerInfoRobot::physicalInfo(), processPacket(), processPacketUdp(), ArCentralForwarder::receiveData(), requestByCommand(), requestOnceByCommand(), requestOnceByCommandUdp(), requestOnceWithString(), requestStopByCommand(), ArHybridForwarderVideo::sendVideoSize(), ArServerHandlerMap::serverGetGoals(), ArServerHandlerMap::serverGetMap(), ArServerHandlerMap::serverGetMapBinary(), ArServerHandlerMap::serverGetMapName(), ArServerModeRatioDrive::serverGetSafeDrive(), ArServerHandlerMapping::serverMappingEnd(), ArServerHandlerMapping::serverMappingStart(), ArServerHandlerMapping::serverMappingStatus(), ArServerHandlerCameraCollection::setParams(), setTcpOnlyFromServer(), startNonBlockingDisconnect(), ArServerHandlerMap::writeLinesToClient(), ArServerHandlerMap::writeMapToClient(), and ArServerHandlerMap::writePointsToClient(). |
|
Send a packet over UDP (unless client only wants tcp then sends over tcp).
Definition at line 504 of file ArClientBase.cpp. References myUdpSin, myUdpSocket, ArSocket::sendTo(), setupPacket(), and trackPacketSent(). Referenced by ArServerHandlerCamera::cameraInfo(), ArServerHandlerCamera::cameraUpdate(), exampleArrowsDrawingNetCallback(), exampleDotsDrawingNetCallback(), exampleHomeDrawingNetCallback(), exampleXDrawingNetCallback(), ArServerInfoSensor::getSensorCumulative(), ArServerInfoSensor::getSensorCurrent(), ArServerInfoSensor::getSensorList(), ArServerHandlerCommMonitor::handleAckCommUdp(), ArServerHandlerCamera::handleGetCameraData(), ArServerHandlerCamera::handleGetCameraInfo(), ArClientSwitchManager::netCentralHeartbeat(), ArServerInfoDrawings::netRangeDeviceCumulative(), ArServerInfoDrawings::netRangeDeviceCurrent(), processPacket(), ArCentralForwarder::receiveData(), requestOnceByCommandUdp(), ArHybridForwarderVideo::sendVideo(), and ArServerInfoRobot::update(). |
|
Sets the time to allow for connection (default 3).
Definition at line 147 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myTimeoutTime, and ArMutex::unlock(). Referenced by ArHybridForwarderVideo::ArHybridForwarderVideo(). |
|
Sets the optional name of the connected robot for debugging purposes.
Definition at line 67 of file ArClientBase.cpp. References myLogPrefix, and myRobotName. |
|
Sets the 'key' needed to connect to the server.
Definition at line 1620 of file ArClientBase.cpp. References ArMutex::lock(), ArLog::log(), myDataMutex, myServerKey, and ArMutex::unlock(). Referenced by ArClientSimpleConnector::connectClient(), and ArClientSwitchManager::runThread(). |
|
Sets it so we only get TCP data from the server not UDP.
Definition at line 1552 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myTcpOnlyFrom, sendPacketTcp(), ArNetPacket::setCommand(), and ArMutex::unlock(). |
|
Sets it so we only send TCP data to the server.
Definition at line 1563 of file ArClientBase.cpp. References ArMutex::lock(), myDataMutex, myTcpOnlyTo, and ArMutex::unlock(). |
|
Definition at line 481 of file ArClientBase.cpp. References myState, STATE_FAILED_CONNECTION, and STATE_NO_CONNECTION. Referenced by sendPacketTcp(), and sendPacketUdp(). |
|
This method should be called in threads that should not block (such as the main GUI thread). The call should be followed by a delay of one second, followed by a call to finishNonBlockingDisconnect(). Definition at line 457 of file ArClientBase.cpp. References ArLog::log(), myQuiet, myTcpSender, ArNetPacketSenderTcp::sendData(), sendPacketTcp(), and ArNetPacket::setCommand(). Referenced by disconnect(). |
|
Definition at line 1665 of file ArClientBase.cpp. References ArMutex::lock(), myPacketTrackingMutex, myTrackingReceivedMap, and ArMutex::unlock(). Referenced by processPacket(). |
|
Definition at line 1646 of file ArClientBase.cpp. References ArMutex::lock(), myPacketTrackingMutex, myTrackingSentMap, and ArMutex::unlock(). Referenced by sendPacketTcp(), and sendPacketUdp(). |
|
true if a server connection attempt failed because the server rejected the username or password, false if the connection failed for another reason, or the username/password were accepted.
Definition at line 125 of file ArClientBase.h. References myState, and STATE_REJECTED. Referenced by main(), and ArClientSwitchManager::runThread(). |
|
Definition at line 335 of file ArClientBase.h. Referenced by processPacket(). |
|
Definition at line 320 of file ArClientBase.h. Referenced by addDisconnectOnErrorCB(), addServerShutdownCB(), loopOnce(), processPacket(), remDisconnectOnErrorCB(), and remServerShutdownCB(). |
|
Definition at line 339 of file ArClientBase.h. Referenced by processPacket(). |
|
Definition at line 317 of file ArClientBase.h. |
|
Definition at line 321 of file ArClientBase.h. Referenced by addCycleCallback(), loopOnce(), and remCycleCallback(). |
|
Definition at line 288 of file ArClientBase.h. Referenced by addCycleCallback(), loopOnce(), and remCycleCallback(). |
|
Definition at line 316 of file ArClientBase.h. Referenced by dataExists(), getHost(), getLastPacketReceived(), getName(), internalBlockingConnect(), isTcpOnlyFromServer(), isTcpOnlyToServer(), logDataList(), logTracking(), processPacket(), processPacketUdp(), requestOnceWithString(), setConnectTimeoutTime(), setServerKey(), setTcpOnlyFromServer(), and setTcpOnlyToServer(). |
|
Definition at line 287 of file ArClientBase.h. Referenced by addDisconnectOnErrorCB(), loopOnce(), and remDisconnectOnErrorCB(). |
|
Definition at line 308 of file ArClientBase.h. Referenced by getHost(), and internalBlockingConnect(). |
|
Definition at line 326 of file ArClientBase.h. Referenced by addHandler(), buildList(), clear(), getDataMap(), getName(), logDataList(), processPacket(), and remHandler(). |
|
Definition at line 336 of file ArClientBase.h. Referenced by processPacket(), and processPacketUdp(). |
|
Definition at line 285 of file ArClientBase.h. Referenced by clear(), getLastPacketReceived(), processPacket(), and processPacketUdp(). |
|
Optional prefix to be inserted at the start of log messages.
Definition at line 282 of file ArClientBase.h. Referenced by request(), requestOnce(), requestOnceUdp(), requestOnceWithString(), requestStop(), and setRobotName(). |
|
Definition at line 318 of file ArClientBase.h. Referenced by addHandler(), findCommandFromName(), processPacket(), and remHandler(). |
|
Definition at line 324 of file ArClientBase.h. Referenced by addHandler(), buildList(), clear(), dataExists(), findCommandFromName(), remHandler(), and requestOnceWithString(). |
|
Definition at line 322 of file ArClientBase.h. Referenced by logTracking(), resetTracking(), trackPacketReceived(), and trackPacketSent(). |
|
Definition at line 310 of file ArClientBase.h. Referenced by internalBlockingConnect(), and processPacket(). |
|
Definition at line 345 of file ArClientBase.h. Referenced by ArClientBase(). |
|
Definition at line 346 of file ArClientBase.h. Referenced by ArClientBase(). |
|
Definition at line 307 of file ArClientBase.h. Referenced by clear(), internalBlockingConnect(), internalConnect(), internalStartUdp(), loopOnce(), processPacket(), processPacketUdp(), and startNonBlockingDisconnect(). |
|
Definition at line 296 of file ArClientBase.h. Referenced by buildList(), clear(), and getReceivedArgRetList(). |
|
Definition at line 295 of file ArClientBase.h. Referenced by buildList(), clear(), and getReceivedDataList(). |
|
Definition at line 297 of file ArClientBase.h. Referenced by buildList(), clear(), and getReceivedGroupAndFlagsList(). |
|
Definition at line 348 of file ArClientBase.h. Referenced by clear(), getRejected(), and processPacket(). |
|
Definition at line 349 of file ArClientBase.h. Referenced by clear(), getRejectedString(), and processPacket(). |
|
Optional robot name for logging.
Definition at line 280 of file ArClientBase.h. Referenced by getRobotName(), and setRobotName(). |
|
Definition at line 337 of file ArClientBase.h. Referenced by processPacket(), and setServerKey(). |
|
Definition at line 331 of file ArClientBase.h. Referenced by clear(), processPacket(), and processPacketUdp(). |
|
Definition at line 333 of file ArClientBase.h. |
|
Definition at line 286 of file ArClientBase.h. Referenced by addServerShutdownCB(), processPacket(), and remServerShutdownCB(). |
|
Definition at line 314 of file ArClientBase.h. Referenced by internalBlockingConnect(). |
|
Definition at line 298 of file ArClientBase.h. Referenced by finishNonBlockingDisconnect(), internalBlockingConnect(), internalSwitchState(), isConnected(), loopOnce(), processPacket(), processPacketUdp(), setupPacket(), and wasRejected(). |
|
Definition at line 319 of file ArClientBase.h. |
|
Definition at line 299 of file ArClientBase.h. Referenced by internalSwitchState(). |
|
Definition at line 305 of file ArClientBase.h. Referenced by clear(), internalBlockingConnect(), internalStartUdp(), isTcpOnlyFromServer(), loopOnce(), processPacket(), and setTcpOnlyFromServer(). |
|
Definition at line 303 of file ArClientBase.h. Referenced by clear(), internalBlockingConnect(), internalStartUdp(), isTcpOnlyToServer(), processPacket(), requestOnceByCommandUdp(), and setTcpOnlyToServer(). |
|
Definition at line 341 of file ArClientBase.h. Referenced by ArClientBase(), internalBlockingConnect(), and loopOnce(). |
|
Definition at line 340 of file ArClientBase.h. Referenced by ArClientBase(), loopOnce(), sendPacketTcp(), and startNonBlockingDisconnect(). |
|
Definition at line 343 of file ArClientBase.h. Referenced by ArClientBase(), finishNonBlockingDisconnect(), getTcpAddr(), getTcpSocket(), internalBlockingConnect(), internalConnect(), internalStartUdp(), logTracking(), loopOnce(), and resetTracking(). |
|
Definition at line 312 of file ArClientBase.h. Referenced by clear(), getConnectTimeoutTime(), internalBlockingConnect(), and setConnectTimeoutTime(). |
|
Definition at line 367 of file ArClientBase.h. Referenced by logTracking(), resetTracking(), and trackPacketReceived(). |
|
Definition at line 366 of file ArClientBase.h. Referenced by logTracking(), resetTracking(), and trackPacketSent(). |
|
Definition at line 351 of file ArClientBase.h. Referenced by logTracking(), and resetTracking(). |
|
Definition at line 300 of file ArClientBase.h. Referenced by clear(), internalBlockingConnect(), and processPacketUdp(). |
|
Definition at line 301 of file ArClientBase.h. Referenced by clear(), internalBlockingConnect(), and processPacket(). |
|
Definition at line 334 of file ArClientBase.h. Referenced by internalConnect(), internalStartUdp(), and processPacket(). |
|
Definition at line 342 of file ArClientBase.h. Referenced by ArClientBase(), and loopOnce(). |
|
Definition at line 328 of file ArClientBase.h. Referenced by internalStartUdp(), processPacket(), processPacketUdp(), and sendPacketUdp(). |
|
Definition at line 329 of file ArClientBase.h. Referenced by internalStartUdp(). |
|
Definition at line 344 of file ArClientBase.h. Referenced by ArClientBase(), finishNonBlockingDisconnect(), getUdpSocket(), internalBlockingConnect(), internalStartUdp(), logTracking(), loopOnce(), resetTracking(), and sendPacketUdp(). |
|
Definition at line 309 of file ArClientBase.h. Referenced by internalBlockingConnect(), and processPacket(). |