Fawkes API  Fawkes Development Version
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 
29 #include <list>
30 
31 namespace fawkes {
32 
33 class StreamSocket;
34 class FawkesNetworkServerThread;
35 class FawkesNetworkMessage;
36 class FawkesNetworkMessageQueue;
37 class WaitCondition;
38 class Mutex;
39 class FawkesNetworkServerClientSendThread;
40 
42 {
43 public:
46 
47  virtual void once();
48  virtual void loop();
49 
50  unsigned int clid() const;
51  void set_clid(unsigned int client_id);
52 
53  bool alive() const;
54  void enqueue(FawkesNetworkMessage *msg);
55 
56  void force_send();
57  void connection_died();
58 
59  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
60 protected:
61  virtual void
62  run()
63  {
64  Thread::run();
65  }
66 
67 private:
68  void recv();
69 
70  unsigned int _clid;
71  bool _alive;
72  StreamSocket * _s;
74  FawkesNetworkMessageQueue *_inbound_queue;
75 
77 };
78 
79 } // end namespace fawkes
80 
81 #endif
A LockQueue of FawkesNetworkMessage to hold messages in inbound and outbound queues.
Definition: message_queue.h:33
Representation of a message that is sent over the network.
Definition: message.h:77
Sending thread for a Fawkes client connected to the server.
Fawkes Network Client Thread for server.
unsigned int clid() const
Get client ID.
void force_send()
Force sending of all pending outbound messages.
virtual void run()
Stub to see name in backtrace for easier debugging.
bool alive() const
Check aliveness of connection.
void set_clid(unsigned int client_id)
Set client ID.
void connection_died()
Connection died notification.
void enqueue(FawkesNetworkMessage *msg)
Enqueue message to outbound queue.
FawkesNetworkServerClientThread(StreamSocket *s, FawkesNetworkServerThread *parent)
Constructor.
virtual void once()
Execute an action exactly once.
Fawkes Network Thread.
Definition: server_thread.h:49
TCP stream socket over IP.
Definition: stream.h:32
Thread class encapsulation of pthreads.
Definition: thread.h:46
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:918
Fawkes library namespace.