Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
server_client_thread.h
1 
2 /***************************************************************************
3  * client_thread.h - Thread to handle Fawkes network client
4  *
5  * Created: Fri Nov 17 15:30:15 2006
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __NETCOMM_FAWKES_CLIENT_THREAD_H_
25 #define __NETCOMM_FAWKES_CLIENT_THREAD_H_
26 
27 #include <core/threading/thread.h>
28 #include <list>
29 
30 namespace fawkes {
31 
32 class StreamSocket;
33 class FawkesNetworkServerThread;
34 class FawkesNetworkMessage;
35 class FawkesNetworkMessageQueue;
36 class WaitCondition;
37 class Mutex;
38 class FawkesNetworkServerClientSendThread;
39 
41 {
42  public:
45 
46  virtual void once();
47  virtual void loop();
48 
49  unsigned int clid() const;
50  void set_clid(unsigned int client_id);
51 
52  bool alive() const;
53  void enqueue(FawkesNetworkMessage *msg);
54 
55  void force_send();
56  void connection_died();
57 
58  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
59  protected: virtual void run() { Thread::run(); }
60 
61  private:
62  void recv();
63 
64  unsigned int _clid;
65  bool _alive;
66  StreamSocket *_s;
68  FawkesNetworkMessageQueue *_inbound_queue;
69 
71 };
72 
73 } // end namespace fawkes
74 
75 #endif