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 #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
Fawkes Network Client Thread for server.
A LockQueue of FawkesNetworkMessage to hold messages in inbound and outbound queues.
Definition: message_queue.h:33
Fawkes library namespace.
void force_send()
Force sending of all pending outbound messages.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Representation of a message that is sent over the network.
Definition: message.h:75
Thread class encapsulation of pthreads.
Definition: thread.h:42
Sending thread for a Fawkes client connected to the server.
TCP stream socket over IP.
Definition: stream.h:31
FawkesNetworkServerClientThread(StreamSocket *s, FawkesNetworkServerThread *parent)
Constructor.
virtual void once()
Execute an action exactly once.
void set_clid(unsigned int client_id)
Set client ID.
bool alive() const
Check aliveness of connection.
virtual void run()
Stub to see name in backtrace for easier debugging.
void enqueue(FawkesNetworkMessage *msg)
Enqueue message to outbound queue.
void connection_died()
Connection died notification.
Fawkes Network Thread.
Definition: server_thread.h:46
unsigned int clid() const
Get client ID.