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

ArClientSwitchManager.h

Go to the documentation of this file.
00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARCLIENTSWITCH_H
00027 #define ARCLIENTSWITCH_H
00028 
00029 #include "Aria.h"
00030 #include "ArServerBase.h"
00031 #include "ArClientBase.h"
00032 
00041 class ArClientSwitchManager : public ArASyncTask
00042 {
00043 public:
00044   AREXPORT ArClientSwitchManager(ArServerBase *serverBase, 
00045                                  ArArgumentParser *parser);
00046   AREXPORT virtual ~ArClientSwitchManager();
00048   AREXPORT bool parseArgs(void); 
00050   AREXPORT void logOptions(void) const;
00052   AREXPORT const char *getCentralServerHostName(void);
00054   AREXPORT void clientSwitch(ArNetPacket *packet);
00056   AREXPORT void netCentralHeartbeat(ArServerClient *client, 
00057                                     ArNetPacket *packet);
00059   AREXPORT bool parseFile(const char *fileName);
00060   AREXPORT virtual void *runThread(void *arg);  
00061 protected:
00062   AREXPORT void socketClosed(void);
00063   ArServerBase *myServer;  
00064   ArArgumentParser *myParser;
00065   
00066   ArFileParser myFileParser;
00067   
00068   bool fileUserCallback(ArArgumentBuilder *arg);
00069   bool filePasswordCallback(ArArgumentBuilder *arg);
00070   bool fileServerKeyCallback(ArArgumentBuilder *arg);
00071 
00072   enum State 
00073   {
00074     IDLE, 
00075     TRYING_CONNECTION, 
00076     CONNECTING, 
00077     CONNECTED, 
00078     LOST_CONNECTION 
00079   };
00080   State myState;
00081   ArTime myStartedState;
00082   bool myGaveTimeWarning;
00083   
00084   AREXPORT void switchState(State state);
00085   
00086   ArMutex myDataMutex;
00087 
00088   bool myTryConnection;
00089   ArClientBase *myClient;
00090 
00091   std::string myUser;
00092   std::string myPassword;
00093   std::string myServerKey;
00094 
00095   std::string myCentralServer;
00096   int myCentralServerPort;  
00097   std::string myIdentifier;
00098 
00099   ArRetFunctorC<bool, ArClientSwitchManager> myParseArgsCB;
00100   ArConstFunctorC<ArClientSwitchManager> myLogOptionsCB;
00101   ArFunctorC<ArClientSwitchManager> mySocketClosedCB;
00102   ArFunctor1C<ArClientSwitchManager, ArNetPacket *> mySwitchCB;
00103   ArFunctor2C<ArClientSwitchManager, ArServerClient *, 
00104       ArNetPacket *> myNetCentralHeartbeatCB;
00105   ArRetFunctor1C<bool, ArClientSwitchManager, 
00106       ArArgumentBuilder *> myFileUserCB;
00107   ArRetFunctor1C<bool, ArClientSwitchManager, 
00108       ArArgumentBuilder *> myFilePasswordCB;
00109   ArRetFunctor1C<bool, ArClientSwitchManager, 
00110       ArArgumentBuilder *> myFileServerKeyCB;
00111 };
00112 
00113 
00114 #endif // ARCLIENTSWITCH_H
00115 

Generated on Tue Feb 20 10:51:50 2007 for ArNetworking by  doxygen 1.4.0