#include <EchoLinkDispatcher.h>
This class is a Singleton object. That is, there can be only one object. The constructor is private so the only way to create a Dispatcher object is to use the static method Dispatcher::instance. It will create a new object if it does not exist and return the object if it exists. On error, a NULL pointer will be returned.
Start your application by creating a Dispatcher object. It will then start to listen to the EchoLink ports for incoming connections. Also, be sure to check the returned pointer. If it is NULL, something went wrong. If it is not checked, you will have trouble later when creating Qso objects. So, a typical start in your application would be something like the code below.
#include <iostream> #include <cstdlib> #include <AsyncCppApplication.h> #include <EchoLinkDispatcher.h> using namespace std; using namespace Async; using namespace EchoLink; class MyClass : public SigC::Object { public: MyClass(void) { if (Dispatcher::instance() == 0) { cerr << "Could not create EchoLink listener (Dispatcher) object\n"; exit(1); } Dispatcher::instance()->incomingConnection.connect(slot(*this, &MyClass::onIncomingConnection)); } private: void onIncomingConnection(const IpAddress& ip, const string& callsign, const string& name) { cerr << "Incoming connection from " << ip << ": " << callsign << " (" << name << ")\n"; // Find out the station data by using the Directory class // Create a new Qso object to accept the connection } }; int main(int argc, char **argv) { CppApplication app; // or QtApplication MyClass my_class; app.exec(); }
Definition at line 144 of file EchoLinkDispatcher.h.
EchoLink::Dispatcher::~Dispatcher | ( | void | ) |
Destructor.
static void EchoLink::Dispatcher::setPortBase | ( | int | base | ) | [static] |
Set the port base for the two UDP ports.
base | The port base to use |
static Dispatcher* EchoLink::Dispatcher::instance | ( | void | ) | [static] |
Get the Singleton instance.
friend class Qso [friend] |
Definition at line 195 of file EchoLinkDispatcher.h.
SigC::Signal3<void, const Async::IpAddress&, const std::string&, const std::string&> EchoLink::Dispatcher::incomingConnection |
A signal that is emitted when someone is trying to connect.
callsign | The callsign of the connecting station | |
name | The name of the connecting station |
Definition at line 190 of file EchoLinkDispatcher.h.