Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

phClientHandler.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission : 
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009     This file is part of Phission.
00010 
00011     Phission is free software; you can redistribute it and/or modify
00012     it under the terms of the GNU General Public License as published by
00013     the Free Software Foundation; either version 2 of the License, or
00014     (at your option) any later version.
00015 
00016     Phission is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019     GNU General Public License for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with Phission; if not, write to the Free Software
00023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025  ---------------------------------------------------------------------------*/
00026 /* -------------------------------------------------------------------------- *
00027  * phClientHandler.h: Header for the client handler that the server spawns to *
00028  * handle multiple client requests.                                           *
00029  * -------------------------------------------------------------------------- */
00030 #ifndef PHCLIENTHANDLER_H
00031 #define PHCLIENTHANDLER_H
00032 
00033 #include <phission.h>
00034 #include <phMessage.h>
00035 #include <phLamportSystem.h>
00036 #include <limits.h>
00037 
00038 /* -------------------------------------------------------------------------- */
00039 class phClientHandler : public phThread
00040 {
00041 private:
00042     phLamportSystem *m_system;
00043 
00044     /* m_sock: this is the socket object used to communicate with the
00045      * client */
00046     phSocket        *m_sock;
00047 
00048     uint32_t        m_controller_id;
00049     uint32_t        m_client_id;
00050     phMessage       m_message;
00051 
00052     
00053     /* receive_request: This receives a request from the client using
00054      * the m_sock socket variable */
00055     int receive_message();
00056     
00057     /* dispatch: does any necessary setup required before
00058      * analyzing the message to determine which action should be
00059      * taken to handle the message. 
00060      * If the method is unrecognized/unsupported by this
00061      * server, then the error reply message is send back to the client */
00062     int dispatch( );
00063     
00064     /* handle_client_hello: This is called by dispatch. */
00065     int handle_client_hello();
00066     int handle_client_goodbye();
00067     
00068     /* send_client_message: This sends */
00069     int send_client_message( uint32_t message = phCLIENT_INVALID_MSG,
00070                              uint32_t mutex_id = phID_INVALID );
00071 
00072 public:
00073     /* phClientHandler: The object constructor allows
00074      * the phServerThread to set the sock in the constructor.
00075      * If it isn't set upon creation, setSocket is used later */
00076     phClientHandler(uint32_t controller_id  = phID_INVALID,
00077                     phSocket *sock          = NULL,
00078                     phLamportSystem *system = NULL);
00079     virtual ~phClientHandler();
00080 
00081     /* Assigned/retreive socket informatino for the client handler */
00082     int         setSocket(phSocket *sock);
00083     phSocket    *getSocket();
00084     
00085     int setControllerId(uint32_t controller_id);
00086     uint32_t getControllerId();
00087 
00088     int setClientId(uint32_t client_id);
00089     uint32_t getClientId();
00090 
00091     int setSystem( phLamportSystem *system );
00092     phLamportSystem *getSystem();
00093     
00094     /* phThread overloaded methods */
00095     /* run: This is where all the communication business happens. */
00096     virtual int run();
00097     /* If there is something that can block, wakeup tries to 
00098      * unblock it */
00099     virtual int wakeup();
00100     /* cleanup: this resets/cleans up any class member variables in case someone
00101      * wants to reuse this object after the thread has shutdown */
00102     virtual int cleanup();
00103     /* In the case of error starting up, this method is called */
00104     virtual int error();
00105 };
00106 
00107 
00108 #endif /* PHCLIENTHANDLER_H */




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:05 2007 for phission by  doxygen 1.4.4