EchoLib 1.3.5
EchoLinkDispatcher.h
Go to the documentation of this file.
1
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&, const std::string&> incomingConnection;
211
212 protected:
213
214 private:
215 friend class Qso;
216
217 typedef void (Qso::*CtrlInputHandler)(unsigned char *buf, int len);
218 typedef void (Qso::*AudioInputHandler)(unsigned char *buf, int len);
219 typedef struct
220 {
221 Qso * con;
222 CtrlInputHandler cih;
223 AudioInputHandler aih;
224 } ConData;
225 typedef std::map<Async::IpAddress, ConData> ConMap;
226
227 static const int DEFAULT_PORT_BASE = 5198;
228
229 static int port_base;
230 static Async::IpAddress bind_ip;
231 static Dispatcher * the_instance;
232
233 ConMap con_map;
234 Async::UdpSocket * ctrl_sock;
235 Async::UdpSocket * audio_sock;
236
237 bool registerConnection(Qso *con, CtrlInputHandler cih,
238 AudioInputHandler aih);
239 void unregisterConnection(Qso *con);
240
241 Dispatcher(void);
242 void ctrlDataReceived(const Async::IpAddress& ip, uint16_t port,
243 void *buf, int len);
244 void audioDataReceived(const Async::IpAddress& ip, uint16_t port,
245 void *buf, int len);
246 void printData(const char *buf, int len);
247
248 // These functions are accessed by the Qso class
249 bool sendCtrlMsg(const Async::IpAddress& to, const void *buf, int len);
250 bool sendAudioMsg(const Async::IpAddress& to, const void *buf, int len);
251
252}; /* class Dispatcher */
253
254
255} /* namespace */
256
257#endif /* ECHOLINK_DISPATCHER_INCLUDED */
258
259
260
261/*
262 * This file has not been truncated
263 */
264