EchoLib  0.14.0
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions
EchoLink::Qso Class Reference

A class for creating an EchoLink connection. More...

#include <EchoLinkQso.h>

List of all members.

Classes

Public Types

Public Member Functions

Public Attributes

Protected Member Functions


Detailed Description

A class for creating an EchoLink connection.

Author:
Tobias Blomberg
Date:
2003-03-11

This class is used to create a connection to another EchoLink node. It only handles outgoing connections. To handle incoming connections, have a look at EchoLink::Dispatcher. However, when an incoming connection has been signalled by the dispatcher, a Qso object should be created to complete the connection. This logic should be glued together in the main program.

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();
}
Examples:

EchoLinkQso_demo.cpp.


Member Enumeration Documentation

The type of the connection state.

Enumerator:
STATE_DISCONNECTED 

No connection to the remote station.

STATE_CONNECTING 

Connecting to remote station (not established)

STATE_BYE_RECEIVED 

Received a disconnect request from remote station.

STATE_CONNECTED 

Connected to remote station.

Definition at line 174 of file EchoLinkQso.h.


Constructor & Destructor Documentation

EchoLink::Qso::Qso ( const Async::IpAddress &  ip,
const std::string &  callsign = "",
const std::string &  name = "",
const std::string &  info = "" 
)

Constructor.

Parameters:
ipThe IP-address of the remote station
callsignCallsign of local user (not remote callsign)
nameName of local user (not remote name)
infoLocal information to send upon connect
EchoLink::Qso::~Qso ( void  )

Destructor.


Member Function Documentation

bool EchoLink::Qso::accept ( void  )

Accept an incoming connection.

Returns:
Returns true if the connect message was sent successfully or false on failure

Use this function to accept an incoming connection. Incoming connections are signalled through the EchoLink::Dispatcher. When an incoming connection has been received, a Qso object should be created and this function should be called to accept the connection. Be sure to check that a valid callsign has connected. At least if the EchoLink node is connected to a radio transmitter.

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.

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.

bool EchoLink::Qso::connect ( void  )

Initiate a connection to the remote station.

Returns:
Returns true if the connect message was sent ok or false on failure

Use this function to connect to the remote station. The StateChange signal will be emitted to indicate that a connection is in progress. When the connection has been established, the stateChange signal will be emitted again. On failure to connect, the stateChange signal will be emitted to indicate that the disconnected state has been entered again.

State EchoLink::Qso::currentState ( void  ) const [inline]

Get the current state of the connection.

Returns:
Return the current connection state (
See also:
State)

Definition at line 373 of file EchoLinkQso.h.

bool EchoLink::Qso::disconnect ( void  )

Initiate a disconnection from the remote station.

Returns:
Returns true if the disconnection message was sent successfully or false on failure
Examples:
EchoLinkQso_demo.cpp.
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.

bool EchoLink::Qso::initOk ( void  ) [inline]

Check that the initialization went ok.

Returns:
Returns true if the initialization was ok or false on failure

This function should be called after creating a new Qso object to make sure everything went well.

Definition at line 205 of file EchoLinkQso.h.

bool EchoLink::Qso::isRemoteInitiated ( void  ) const [inline]

Find out if the connection is remotely initiated or locally initiated.

Returns:
Return true if the connection is remotely initiated or else false.
Note:
Valid when either connect or accept has been called

Definition at line 360 of file EchoLinkQso.h.

const std::string& EchoLink::Qso::localCallsign ( void  ) const [inline]

Retrieve the local callsign.

Returns:
Returns the local callsign

Definition at line 218 of file EchoLinkQso.h.

const std::string& EchoLink::Qso::localInfo ( void  ) const [inline]

Retrieve the local station info.

Returns:
Returns the local station info

Definition at line 244 of file EchoLinkQso.h.

const std::string& EchoLink::Qso::localName ( void  ) const [inline]

Retrieve the local name.

Returns:
Returns the local name

Definition at line 231 of file EchoLinkQso.h.

bool EchoLink::Qso::receivingAudio ( void  ) const [inline]

Find out if there is audio coming in on this connection.

Returns:
Return true if audio is being received or else false.

Definition at line 367 of file EchoLinkQso.h.

const std::string& EchoLink::Qso::remoteCallsign ( void  ) const [inline]

Get the remote callsign.

Returns:
Return the callsign of the remote station
Note:
Valid when the connection has been established

Definition at line 351 of file EchoLinkQso.h.

const Async::IpAddress& EchoLink::Qso::remoteIp ( void  ) const [inline]

Get the IP address of the remote station.

Returns:
Returns the IP address

Definition at line 304 of file EchoLinkQso.h.

const std::string& EchoLink::Qso::remoteName ( void  ) const [inline]

Get the remote name.

Returns:
Return the name of the remote station
Note:
Valid when the connection has been established

Definition at line 338 of file EchoLinkQso.h.

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.

bool EchoLink::Qso::sendAudioRaw ( RawPacket raw_packet)

Send a GSM/SPEEX audio packet to the remote station.

Parameters:
raw_packetThe packet to send

This function can be used to send a GSM/SPEEX packet to the remote station. Probably only useful if you received it from the audioReceivedRaw signal. The raw_packet contains both the network packet and the decoded samples, which is beneficial when the audio frame has to be transcoded (SPEEX -> GSM) prior re-transmission.

bool EchoLink::Qso::sendChatData ( const std::string &  msg)

Send chat data to the remote station.

Parameters:
msgThe message to send
Returns:
Returns true on success or false on failure
bool EchoLink::Qso::sendInfoData ( const std::string &  info = "")

Send info data to the remote station.

Parameters:
infoThe info to send
Returns:
Returns true on success or false on failure
bool EchoLink::Qso::setLocalCallsign ( const std::string &  callsign)

Set the local callsign.

Parameters:
callsignThe callsign to set
Returns:
Returns true on success or false on failure
void EchoLink::Qso::setLocalInfo ( const std::string &  info)

Set the local info.

Parameters:
infoThe informational message that is sent to the remote station upon connection.
bool EchoLink::Qso::setLocalName ( const std::string &  name)

Set the local name (name of station operator)

Parameters:
nameThe name to set
Returns:
Returns true on success or false on failure
void EchoLink::Qso::setRemoteCallsign ( const std::string &  call) [inline]

Set the callsign of the remote station.

Parameters:
callThe callsign to set

Definition at line 344 of file EchoLinkQso.h.

void EchoLink::Qso::setRemoteName ( const std::string &  name) [inline]

Set the name of the remote station.

Parameters:
nameThe name to set

Definition at line 331 of file EchoLinkQso.h.

void EchoLink::Qso::setRemoteParams ( const std::string &  priv)

Set parameters of the remote station connection.

Parameters:
privA private string for passing connection parameters
virtual int EchoLink::Qso::writeSamples ( const float *  samples,
int  count 
) [virtual]

Write samples into this audio sink.

Parameters:
samplesThe buffer containing the samples
countThe number of samples in the buffer
Returns:
Returns the number of samples that has been taken care of

This function is used to write audio into this audio sink. If it returns 0, no more samples could be written. If the returned number of written samples is lower than the count parameter value, the sink is not ready to accept more samples. In this case, the audio source requires sample buffering to temporarily store samples that are not immediately accepted by the sink. The writeSamples function should be called on source buffer updates and after a source output request has been received through the requestSamples function. This function is normally only called from a connected source object.


Member Data Documentation

A signal that is emitted when an audio datagram has been received.

Parameters:
dataA pointer to the buffer that contains the raw audio packet

This signal is emitted whenever an audio packet has been received on the connection. It gives access to the GSM/SPEEX packet. This can be used if the encoded data is going to be retransmitted. In this case it is not good to decode and then encode the data again. It will sound awful.

Definition at line 410 of file EchoLinkQso.h.

SigC::Signal1<void, const std::string&> EchoLink::Qso::chatMsgReceived

A signal that is emitted when a chat message is received.

Parameters:
msgThe received chat message

Definition at line 385 of file EchoLinkQso.h.

SigC::Signal1<void, const std::string&> EchoLink::Qso::infoMsgReceived

A signal that is emitted when a station info message is received.

Parameters:
msgThe received message

Definition at line 379 of file EchoLinkQso.h.

SigC::Signal1<void, bool> EchoLink::Qso::isReceiving

A signal that is emitted when the audio receive state changes.

Parameters:
is_receivingIs true when audio is being received and false when not
Note:
This signal can be used to control a reception indicator

Definition at line 399 of file EchoLinkQso.h.

SigC::Signal1<void, State> EchoLink::Qso::stateChange

A signal that is emitted when the connection state changes.

Parameters:
stateThe new connection state

Definition at line 391 of file EchoLinkQso.h.


The documentation for this class was generated from the following file: