EchoLib 1.3.7
EchoLinkDispatcher.h
Go to the documentation of this file.
1
31
35
36
37#ifndef ECHOLINK_DISPATCHER_INCLUDED
38#define ECHOLINK_DISPATCHER_INCLUDED
39
40
41/****************************************************************************
42 *
43 * System Includes
44 *
45 ****************************************************************************/
46
47#include <sigc++/sigc++.h>
48
49#include <map>
50
51
52/****************************************************************************
53 *
54 * Project Includes
55 *
56 ****************************************************************************/
57
58#include <AsyncIpAddress.h>
59#include <AsyncUdpSocket.h>
60
61
62/****************************************************************************
63 *
64 * Local Includes
65 *
66 ****************************************************************************/
67
68
69
70/****************************************************************************
71 *
72 * Forward declarations
73 *
74 ****************************************************************************/
75
76
77
78/****************************************************************************
79 *
80 * Namespace
81 *
82 ****************************************************************************/
83
84namespace EchoLink
85{
86
87/****************************************************************************
88 *
89 * Forward declarations of classes inside of the declared namespace
90 *
91 ****************************************************************************/
92
93class Qso;
94
95
96/****************************************************************************
97 *
98 * Defines & typedefs
99 *
100 ****************************************************************************/
101
102
103
104/****************************************************************************
105 *
106 * Exported Global Variables
107 *
108 ****************************************************************************/
109
110
111
112/****************************************************************************
113 *
114 * Class definitions
115 *
116 ****************************************************************************/
117
144class Dispatcher : public sigc::trackable
145{
146 public:
157 static void setPortBase(int base);
158
171 static void setBindAddr(const Async::IpAddress& ip);
172
188 static Dispatcher *instance(void);
189
193 static void deleteInstance(void);
194
199
209 sigc::signal<void(const Async::IpAddress&, const std::string&,
210 const std::string&,
211 const std::string&)> incomingConnection;
212
213 protected:
214
215 private:
216 friend class Qso;
217
218 typedef void (Qso::*CtrlInputHandler)(unsigned char *buf, int len);
219 typedef void (Qso::*AudioInputHandler)(unsigned char *buf, int len);
220 typedef struct
221 {
222 Qso * con;
223 CtrlInputHandler cih;
224 AudioInputHandler aih;
225 } ConData;
226 typedef std::map<Async::IpAddress, ConData> ConMap;
227
228 static const int DEFAULT_PORT_BASE = 5198;
229
230 static int port_base;
231 static Async::IpAddress bind_ip;
232 static Dispatcher * the_instance;
233
234 ConMap con_map;
235 Async::UdpSocket * ctrl_sock;
236 Async::UdpSocket * audio_sock;
237
238 bool registerConnection(Qso *con, CtrlInputHandler cih,
239 AudioInputHandler aih);
240 void unregisterConnection(Qso *con);
241
242 Dispatcher(void);
243 void ctrlDataReceived(const Async::IpAddress& ip, uint16_t port,
244 void *buf, int len);
245 void audioDataReceived(const Async::IpAddress& ip, uint16_t port,
246 void *buf, int len);
247 void printData(const char *buf, int len);
248
249 // These functions are accessed by the Qso class
250 bool sendCtrlMsg(const Async::IpAddress& to, const void *buf, int len);
251 bool sendAudioMsg(const Async::IpAddress& to, const void *buf, int len);
252
253}; /* class Dispatcher */
254
255
256} /* namespace */
257
258#endif /* ECHOLINK_DISPATCHER_INCLUDED */
259
260
261
262/*
263 * This file has not been truncated
264 */
265