Fawkes API Fawkes Development Version

server_client_thread.h

00001 
00002 /***************************************************************************
00003  *  client_thread.h - Thread to handle Fawkes network client
00004  *
00005  *  Created: Fri Nov 17 15:30:15 2006
00006  *  Copyright  2006  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program 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 Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __NETCOMM_FAWKES_CLIENT_THREAD_H_
00025 #define __NETCOMM_FAWKES_CLIENT_THREAD_H_
00026 
00027 #include <core/threading/thread.h>
00028 #include <list>
00029 
00030 namespace fawkes {
00031 
00032 class StreamSocket;
00033 class FawkesNetworkServerThread;
00034 class FawkesNetworkMessage;
00035 class FawkesNetworkMessageQueue;
00036 class WaitCondition;
00037 class Mutex;
00038 class FawkesNetworkServerClientSendThread;
00039 
00040 class FawkesNetworkServerClientThread : public Thread
00041 {
00042  public:
00043   FawkesNetworkServerClientThread(StreamSocket *s, FawkesNetworkServerThread *parent);
00044   ~FawkesNetworkServerClientThread();
00045 
00046   virtual void once();
00047   virtual void loop();
00048 
00049   unsigned int clid() const;
00050   void         set_clid(unsigned int client_id);
00051 
00052   bool alive() const;
00053   void enqueue(FawkesNetworkMessage *msg);
00054 
00055   void force_send();
00056   void connection_died();
00057 
00058  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
00059  protected: virtual void run() { Thread::run(); }
00060 
00061  private:
00062   void recv();
00063 
00064   unsigned int                _clid;
00065   bool                        _alive;
00066   StreamSocket               *_s;
00067   FawkesNetworkServerThread  *_parent;
00068   FawkesNetworkMessageQueue  *_inbound_queue;
00069 
00070   FawkesNetworkServerClientSendThread  *_send_slave;
00071 };
00072 
00073 } // end namespace fawkes
00074 
00075 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends