#include <EchoLinkQso.h>
For an example usage, have a look at the code below. A connection is created to ourself. When the connection has been established the information message is automatically transmitted. Upon reception of the information message a disconnect is initiated. When the link has been disconnected the application exits.
#include <iostream> #include <AsyncCppApplication.h> #include <EchoLinkQso.h> using namespace std; using namespace Async; using namespace EchoLink; class MyClass : public SigC::Object { public: MyClass(void) { qso = new Qso(IpAddress("127.0.0.1"), "MYCALL", "MyName", "A test Qso"); if (!qso->initOk()) { delete qso; cerr << "Creation of Qso failed\n"; Application::app().quit(); return; } qso->infoMsgReceived.connect(slot(*this, &MyClass::onInfoMsgReceived)); qso->stateChange.connect(slot(*this, &MyClass::onStateChange)); qso->connect(); } ~MyClass(void) { delete qso; } private: Qso *qso; void onInfoMsgReceived(const string& msg) { cerr << "Info message received: " << msg << endl; qso->disconnect(); } void onStateChange(Qso::State state) { cerr << "State changed to "; switch (state) { case Qso::STATE_DISCONNECTED: cerr << "DISCONNECTED"; Application::app().quit(); break; case Qso::STATE_CONNECTING: cerr << "CONNECTING"; break; case Qso::STATE_CONNECTED: cerr << "CONNECTED"; break; default: break; } cout << endl; } }; int main(int argc, char **argv) { CppApplication app; // or QtApplication MyClass my_class; app.exec(); }
Definition at line 145 of file EchoLinkQso.h.
enum EchoLink::Qso::State |
The type of the connection state.
Definition at line 163 of file EchoLinkQso.h.
EchoLink::Qso::Qso | ( | const Async::IpAddress & | ip, | |
const std::string & | callsign = "" , |
|||
const std::string & | name = "" , |
|||
const std::string & | info = "" | |||
) |
Constructor.
ip | The IP-address of the remote station | |
callsign | Callsign of local user (not remote callsign) | |
name | Name of local user (not remote name) | |
info | Local information to send upon connect |
EchoLink::Qso::~Qso | ( | void | ) |
Destructor.
bool EchoLink::Qso::initOk | ( | void | ) | [inline] |
Check that the initialization went ok.
Definition at line 194 of file EchoLinkQso.h.
bool EchoLink::Qso::setLocalCallsign | ( | const std::string & | callsign | ) |
Set the local callsign.
callsign | The callsign to set |
const std::string& EchoLink::Qso::localCallsign | ( | void | ) | const [inline] |
Retrieve the local callsign.
Definition at line 207 of file EchoLinkQso.h.
bool EchoLink::Qso::setLocalName | ( | const std::string & | name | ) |
Set the local name (name of station operator).
name | The name to set |
const std::string& EchoLink::Qso::localName | ( | void | ) | const [inline] |
Retrieve the local name.
Definition at line 220 of file EchoLinkQso.h.
void EchoLink::Qso::setLocalInfo | ( | const std::string & | info | ) |
Set the local info.
info | The informational message that is sent to the remote station upon connection. |
const std::string& EchoLink::Qso::localInfo | ( | void | ) | const [inline] |
Retrieve the local station info.
Definition at line 233 of file EchoLinkQso.h.
bool EchoLink::Qso::connect | ( | void | ) |
Initiate a connection to the remote station.
bool EchoLink::Qso::accept | ( | void | ) |
Accept an incoming connection.
The difference between the connect and accept functions are that the accept function goes right into the connected state. The remote station is assumed to be present. This might not be true in some strange cases. In such a strange case, the connection will timeout after a while.
bool EchoLink::Qso::disconnect | ( | void | ) |
Initiate a disconnection from the remote station.
bool EchoLink::Qso::sendInfoData | ( | const std::string & | info = "" |
) |
Send info data to the remote station.
info | The info to send |
bool EchoLink::Qso::sendChatData | ( | const std::string & | msg | ) |
Send chat data to the remote station.
msg | The message to send |
const Async::IpAddress& EchoLink::Qso::remoteIp | ( | void | ) | const [inline] |
Get the IP address of the remote station.
Definition at line 293 of file EchoLinkQso.h.
bool EchoLink::Qso::sendAudioRaw | ( | GsmVoicePacket * | packet | ) |
Send audio to the remote station.
buf | A buffer containing 16 bit samples to send | |
len | The length, in samples, of the buffer to send |
packet | The packet to send |
void EchoLink::Qso::setRemoteName | ( | const std::string & | name | ) | [inline] |
Flush the audio send buffer so that all audio get transmitted.
name | The name to set |
Definition at line 330 of file EchoLinkQso.h.
const std::string& EchoLink::Qso::remoteName | ( | void | ) | const [inline] |
Get the remote name.
Definition at line 337 of file EchoLinkQso.h.
void EchoLink::Qso::setRemoteCallsign | ( | const std::string & | call | ) | [inline] |
Set the callsign of the remote station.
call | The callsign to set |
Definition at line 343 of file EchoLinkQso.h.
const std::string& EchoLink::Qso::remoteCallsign | ( | void | ) | const [inline] |
Get the remote callsign.
Definition at line 350 of file EchoLinkQso.h.
bool EchoLink::Qso::isRemoteInitiated | ( | void | ) | const [inline] |
Find out if the connection is remotely initiated or locally initiated.
Definition at line 359 of file EchoLinkQso.h.
bool EchoLink::Qso::receivingAudio | ( | void | ) | const [inline] |
Find out if there is audio coming in on this connection.
Definition at line 366 of file EchoLinkQso.h.
State EchoLink::Qso::currentState | ( | void | ) | const [inline] |
Get the current state of the connection.
Definition at line 372 of file EchoLinkQso.h.
virtual int EchoLink::Qso::writeSamples | ( | const float * | samples, | |
int | count | |||
) | [virtual] |
Write samples into this audio sink.
samples | The buffer containing the samples | |
count | The number of samples in the buffer |
virtual void EchoLink::Qso::flushSamples | ( | void | ) | [virtual] |
Tell the sink to flush the previously written samples.
This function is used to tell the sink to flush previously written samples. When done flushing, the sink should call the sourceAllSamplesFlushed function. This function is normally only called from a connected source object.
virtual void EchoLink::Qso::resumeOutput | ( | void | ) | [virtual] |
Resume audio output to the sink.
This function will be called when the registered audio sink is ready to accept more samples. This function is normally only called from a connected sink object.
virtual void EchoLink::Qso::allSamplesFlushed | ( | void | ) | [protected, virtual] |
The registered sink has flushed all samples.
This function will be called when all samples have been flushed in the registered sink. If it is not reimplemented, a handler must be set that handle the function call. This function is normally only called from a connected sink object.
SigC::Signal1<void, const std::string&> EchoLink::Qso::infoMsgReceived |
A signal that is emitted when a station info message is received.
msg | The received message |
Definition at line 378 of file EchoLinkQso.h.
SigC::Signal1<void, const std::string&> EchoLink::Qso::chatMsgReceived |
A signal that is emitted when a chat message is received.
msg | The received chat message |
Definition at line 384 of file EchoLinkQso.h.
SigC::Signal1<void, State> EchoLink::Qso::stateChange |
A signal that is emitted when the connection state changes.
state | The new connection state |
Definition at line 390 of file EchoLinkQso.h.
SigC::Signal1<void, bool> EchoLink::Qso::isReceiving |
A signal that is emitted when the audio receive state changes.
is_receiving | Is true when audio is being received and false when not |
Definition at line 398 of file EchoLinkQso.h.
SigC::Signal1<void, GsmVoicePacket*> EchoLink::Qso::audioReceivedRaw |
A signal that is emitted when an audio datagram has been received.
buf | A pointer to the buffer that contains the audio | |
len | The number of samples in the buffer A signal that is emitted when an audio datagram has been received | |
data | A pointer to the buffer that contains the raw audio packet |
Definition at line 416 of file EchoLinkQso.h.