Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
server_thread.h
1
2
/***************************************************************************
3
* server_thread.h - Thread to manage Fawkes network clients
4
*
5
* Created: Sun Nov 19 14:27:31 2006
6
* Copyright 2006-2008 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_SERVER_THREAD_H_
25
#define __NETCOMM_FAWKES_SERVER_THREAD_H_
26
27
#include <core/threading/thread.h>
28
#include <core/utils/lock_map.h>
29
#include <netcomm/fawkes/hub.h>
30
#include <netcomm/utils/incoming_connection_handler.h>
31
32
namespace
fawkes {
33
34
class
ThreadCollector;
35
class
Mutex;
36
class
FawkesNetworkServerClientThread;
37
class
NetworkAcceptorThread;
38
class
FawkesNetworkHandler;
39
class
FawkesNetworkMessage;
40
class
FawkesNetworkMessageQueue;
41
class
FawkesNetworkMessageContent;
42
43
class
FawkesNetworkServerThread
44
:
public
Thread
,
45
public
FawkesNetworkHub
,
46
public
NetworkIncomingConnectionHandler
47
{
48
public
:
49
FawkesNetworkServerThread
(
unsigned
int
fawkes_port,
50
ThreadCollector
*thread_collector = 0);
51
virtual
~FawkesNetworkServerThread
();
52
53
virtual
void
loop
();
54
55
virtual
void
add_handler
(
FawkesNetworkHandler
*handler);
56
virtual
void
remove_handler
(
FawkesNetworkHandler
*handler);
57
58
virtual
void
broadcast
(
FawkesNetworkMessage
*msg);
59
virtual
void
broadcast
(
unsigned
short
int
component_id,
unsigned
short
int
msg_id,
60
void
*payload,
unsigned
int
payload_size);
61
virtual
void
broadcast
(
unsigned
short
int
component_id,
unsigned
short
int
msg_id);
62
63
virtual
void
send
(
FawkesNetworkMessage
*msg);
64
virtual
void
send
(
unsigned
int
to_clid,
65
unsigned
short
int
component_id,
unsigned
short
int
msg_id);
66
virtual
void
send
(
unsigned
int
to_clid,
67
unsigned
short
int
component_id,
unsigned
short
int
msg_id,
68
void
*payload,
unsigned
int
payload_size);
69
virtual
void
send
(
unsigned
int
to_clid,
70
unsigned
short
int
component_id,
unsigned
short
int
msg_id,
71
FawkesNetworkMessageContent
*content);
72
73
void
add_connection
(
StreamSocket
*s)
throw
();
74
void
dispatch
(
FawkesNetworkMessage
*msg);
75
76
void
force_send
();
77
78
/** Stub to see name in backtrace for easier debugging. @see Thread::run() */
79
protected
:
virtual
void
run
() {
Thread::run
(); }
80
81
private
:
82
ThreadCollector
*thread_collector;
83
unsigned
int
next_client_id;
84
NetworkAcceptorThread
*acceptor_thread;
85
86
// key: component id, value: handler
87
LockMap<unsigned int, FawkesNetworkHandler *>
handlers;
88
LockMap<unsigned int, FawkesNetworkHandler *>::iterator
hit;
89
90
// key: client id, value: client thread
91
LockMap<unsigned int, FawkesNetworkServerClientThread *>
clients;
92
LockMap<unsigned int, FawkesNetworkServerClientThread *>::iterator
cit;
93
94
FawkesNetworkMessageQueue
*inbound_messages;
95
};
96
97
}
// end namespace fawkes
98
99
#endif
src
libs
netcomm
fawkes
server_thread.h
Generated by
1.8.1.1