Herqq

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Types | Signals | Public Member Functions | Protected Member Functions

# HSsdp Class Reference
Ssdp

This class is used for sending and receiving SSDP messages defined by the UPnP Device Architecture specification. More...

`#include <HSsdp>`

Inherited by HControlPointSsdpHandler, and HDeviceHostSsdpHandler.

List of all members.

## Public Types
enum | DiscoveryRequestMethod { MulticastDiscovery, UnicastDiscovery }
enum | AllowedMessage { None = 0x00, DeviceAvailable = 0x01, DeviceUpdate = 0x02, DeviceUnavailable = 0x04, DiscoveryRequest = 0x08, DiscoveryResponse = 0x10, All = 0x1f }
## Signals
void | discoveryRequestReceived (const Herqq::Upnp::HDiscoveryRequest &msg, const Herqq::Upnp::HEndpoint &source, Herqq::Upnp::HSsdp::DiscoveryRequestMethod requestType)
void | discoveryResponseReceived (const Herqq::Upnp::HDiscoveryResponse &msg, const Herqq::Upnp::HEndpoint &source)
void | resourceAvailableReceived (const Herqq::Upnp::HResourceAvailable &msg, const Herqq::Upnp::HEndpoint &source)
void | deviceUpdateReceived (const Herqq::Upnp::HResourceUpdate &msg, const Herqq::Upnp::HEndpoint &source)
void | resourceUnavailableReceived (const Herqq::Upnp::HResourceUnavailable &msg, const Herqq::Upnp::HEndpoint &source)
## Public Member Functions
| HSsdp (QObject *parent=0)
virtual | ~HSsdp ()
void | setFilter (AllowedMessages allowedMessages)
AllowedMessages | filter () const
bool | init ()
bool | init (const QHostAddress &unicastAddress)
bool | isInitialized () const
HEndpoint | unicastEndpoint () const
qint32 | announcePresence (const HResourceAvailable &msg, qint32 count=1)
qint32 | announcePresence (const HResourceUnavailable &msg, qint32 count=1)
qint32 | announceUpdate (const HResourceUpdate &msg, qint32 count=1)
qint32 | sendDiscoveryRequest (const HDiscoveryRequest &msg, qint32 count=1)
qint32 | sendDiscoveryRequest (const HDiscoveryRequest &msg, const HEndpoint &destination, qint32 count=1)
qint32 | sendDiscoveryResponse (const HDiscoveryResponse &msg, const HEndpoint &destination, qint32 count=1)
## Protected Member Functions
virtual bool | incomingDiscoveryRequest (const HDiscoveryRequest &msg, const HEndpoint &source, DiscoveryRequestMethod requestType)
virtual bool | incomingDiscoveryResponse (const HDiscoveryResponse &msg, const HEndpoint &source)
virtual bool | incomingDeviceAvailableAnnouncement (const HResourceAvailable &msg, const HEndpoint &source)
virtual bool | incomingDeviceUnavailableAnnouncement (const HResourceUnavailable &msg, const HEndpoint &source)
virtual bool | incomingDeviceUpdateAnnouncement (const HResourceUpdate &msg, const HEndpoint &source)

## Detailed Description

This class is used for sending and receiving SSDP messages defined by the UPnP Device Architecture specification.

Simple Service Discovery Protocol (SSDP) is an expired IETF Internet draft on which the UPnP discovery mechanism is built. This class implements only the SSDP functionality mandated by the UPnP Device Architecture specification. This class does not implement the SSDP draft in full.

To use this class, you only need to instantiate it and connect to the exposed signals to receive events when SSDP messages are received. You can also derive a sub-class and override the various virtual member functions to handle the received messages.

Remarks:
  - this class requires an event loop for listening incoming messages
  - this class has thread-affinity, which mandates that the instances of this class has to be used in the thread in which they are located at the time.

## Member Enumeration Documentation

enum DiscoveryRequestMethod

This enumeration specifies the different discovery methods the HSsdp class can run.

Enumerator:

  MulticastDiscovery | This is the default multicast discovery supported both UDA v1.0 and UDA v1.1.
  UnicastDiscovery | The unicast discovery specified in UDA v1.1.

enum AllowedMessage

This enum is used to define a "filter", which specifies which message types are to be processed when encountered.

See also:
  filter(), setFilter()

Enumerator:

  None | No messages are processed.
  DeviceAvailable | Device available messages are processed.
  DeviceUpdate | Device update messages are processed.
  DeviceUnavailable | Device unavailable messages are processed.
  DiscoveryRequest | Discovery request messages are processed.
  DiscoveryResponse | Discovery response messages are processed.
  All | Discovery response messages are processed.

## Constructor & Destructor Documentation

HSsdp | ( | QObject * | parent = `0` | ) |

Creates a new instance.

Parameters:

  parent | specifies the parent `QObject`.

~HSsdp | ( |  | ) | `[virtual]`

Destroys the instance.

## Member Function Documentation

bool incomingDiscoveryRequest | ( | const HDiscoveryRequest & | msg,
|  | const HEndpoint & | source,
|  | DiscoveryRequestMethod | requestType
| ) |  | `[protected, virtual]`

This method is called immediately after receiving a discovery request.

Override this method if you want to handle the message. You can also connect to the discoveryRequestReceived() signal.

Parameters:

  msg | specifies the incoming message.
  source | specifies the source TCP/IP endpoint that sent the message.
  requestType | specifies the type of the incoming discovery request.

Return values:

  true | in case the message was handled successfully and the discoveryRequestReceived() signal should not be sent.
  false | in case the message was not handled and the discoveryRequestReceived() signal should be sent.

See also:
  discoveryRequestReceived()

bool incomingDiscoveryResponse | ( | const HDiscoveryResponse & | msg,
|  | const HEndpoint & | source
| ) |  | `[protected, virtual]`

This method is called immediately after receiving a discovery response.

Override this method if you want to handle message. You can also connect to the discoveryResponseReceived() signal.

Parameters:

  msg | specifies the incoming message.
  source | specifies the source TCP/IP endpoint that sent the message.

Return values:

  true | in case the message was handled successfully and the discoveryResponseReceived() signal should not be sent.
  false | in case the message was not handled and the discoveryResponseReceived() signal should be sent.

See also:
  discoveryResponseReceived()

bool incomingDeviceAvailableAnnouncement | ( | const HResourceAvailable & | msg,
|  | const HEndpoint & | source
| ) |  | `[protected, virtual]`

This method is called immediately after receiving a device available announcement.

Override this method if you want to handle message. You can also connect to the discoveryRequestReceived() signal.

Parameters:

  msg | specifies the incoming message.
  source | specifies the source TCP/IP endpoint that sent the message.

Return values:

  true | in case the message was handled successfully and the resourceAvailableReceived() signal should not be sent.
  false | in case the message was not handled and the resourceAvailableReceived() signal should be sent.

See also:
  resourceAvailableReceived()

bool incomingDeviceUnavailableAnnouncement | ( | const HResourceUnavailable & | msg,
|  | const HEndpoint & | source
| ) |  | `[protected, virtual]`

This method is called immediately after receiving a device unavailable announcement.

Override this method if you want to handle message. You can also connect to the resourceUnavailableReceived() signal.

Parameters:

  msg | specifies the incoming message.
  source | specifies the source TCP/IP endpoint that sent the message.

Return values:

  true | in case the message was handled successfully and the resourceUnavailableReceived() signal should not be sent.
  false | in case the message was not handled and the resourceUnavailableReceived() signal should be sent.

See also:
  resourceUnavailableReceived()

bool incomingDeviceUpdateAnnouncement | ( | const HResourceUpdate & | msg,
|  | const HEndpoint & | source
| ) |  | `[protected, virtual]`

This method is called immediately after receiving a device update announcement.

Override this method if you want to handle message. You can also connect to the deviceUpdateRecieved() signal.

Parameters:

  msg | specifies the incoming message.
  source | specifies the source TCP/IP endpoint that sent the message.

Return values:

  true | in case the message was handled successfully and the deviceUpdateRecieved() signal should not be sent.
  false | in case the message was not handled and the deviceUpdateRecieved() signal should be sent.

See also:
  deviceUpdateRecieved()

void setFilter | ( | AllowedMessages | allowedMessages | ) |

Sets the filter of what message types are accepted for processing.

The default is HSsdp::All.

Parameters:

  allowedMessages | defines the message types the instance should accept for further processing. Other message types will be silently ignored.

See also:
  filter()

HSsdp::AllowedMessages filter | ( |  | ) | const

Returns the message types that are currently accepted for processing.

Default is HSsdp::All.

Returns:
  The message types that are currently accepted for processing.

See also:
  setFilter()

bool init | ( |  | ) |

Sets the instance to listen the network for SSDP messages and and attempts to init the unicast socket of the instance to the address of the first found network address that is up and that is not loopback.

If no such interface is found the loopback address is used.

Return values:

  true | in case the instances was successfully bound to some address.
  false | in case the instance could not be bound or the instance was already bound.

Remarks:
  `HSsdp` has to be bound to receive messages of any type.

bool init | ( | const QHostAddress & | unicastAddress | ) |

Sets the instance to listen the network for SSDP messages and attempts to init a unicast socket of the instance to the specified address.

Parameters:

  unicastAddress | specifies the address that should be used for unicast messaging.

Return values:

  true | in case the instance was successfully bound to the specified address.
  false | in case the instance could not be bound or the instance was already bound to the specified address.

Remarks:
  `HSsdp` has to be bound to receive messages of any type.

bool isInitialized | ( |  | ) | const

Indicates if the instance is bound to listen for messages using one or more network interfaces.

Returns:
  true in case the instance is bound to listen for messages using one or more network interfaces.

HEndpoint unicastEndpoint | ( |  | ) | const

Returns the UDP endpoint that is used for unicast communication.

Returns:
  The UDP endpoint that is used for unicast communication.

qint32 announcePresence | ( | const HResourceAvailable & | msg,
|  | qint32 | count = `1`
| ) |  |

Sends the specified device availability announcement.

Parameters:

  msg | specifies the announcement to send.
  count | specifies how many times the announcement is send. The default is 1.

Returns:
  The number of messages sent, 0 in case no messages was sent or -1 in case the provided message is not valid.

qint32 announcePresence | ( | const HResourceUnavailable & | msg,
|  | qint32 | count = `1`
| ) |  |

Sends the specified device availability announcement.

Parameters:

  msg | specifies the announcement to send.
  count | specifies how many times the announcement is send. The default is 1.

Returns:
  The number of messages sent, 0 in case no messages was sent or -1 in case the provided message is not valid.

qint32 announceUpdate | ( | const HResourceUpdate & | msg,
|  | qint32 | count = `1`
| ) |  |

Sends the specified device update announcement.

Parameters:

  msg | specifies the message to send.
  count | specifies how many times the announcement is send. The default is 1.

Returns:
  The number of messages sent, 0 in case no messages was sent or -1 in case the provided message is not valid.

qint32 sendDiscoveryRequest | ( | const HDiscoveryRequest & | msg,
|  | qint32 | count = `1`
| ) |  |

Sends the specified discovery request.

Sends the specified discovery request to a multicast address 239.255.255.250.

Parameters:

  msg | specifies the announcement to send.
  count | specifies how many times the announcement is send. The default is 1.

Returns:
  The number of messages sent, 0 in case no messages was sent or -1 in case the provided message is not valid.

qint32 sendDiscoveryRequest | ( | const HDiscoveryRequest & | msg,
|  | const HEndpoint & | destination,
|  | qint32 | count = `1`
| ) |  |

Sends the specified discovery request.

Sends the specified discovery request to a specified address. The address can be an unicast address or a multicast address.

Parameters:

  msg | specifies the announcement to send.
  destination | specifies the target UDP endpoint of the message. If the port of the specified endpoint is set to zero the message is sent to the specified host address using the default port 1900.
  count | specifies how many times the announcement is send. The default is 1.

Returns:
  The number of messages sent, 0 in case no messages was sent or -1 in case the provided message or the destination is not valid.

qint32 sendDiscoveryResponse | ( | const HDiscoveryResponse & | msg,
|  | const HEndpoint & | destination,
|  | qint32 | count = `1`
| ) |  |

Sends the specified discovery response.

Parameters:

  msg | specifies the announcement to send.
  destination | specifies the target of the response. If the port of the specified endpoint is set to zero the message is sent to the specified host address using the default port 1900.
  count | specifies how many times the announcement is send. The default is 1.

Returns:
  The number of messages sent, 0 in case no messages was sent or -1 in case the provided message is not valid.

void discoveryRequestReceived | ( | const Herqq::Upnp::HDiscoveryRequest & | msg,
|  | const Herqq::Upnp::HEndpoint & | source,
|  | Herqq::Upnp::HSsdp::DiscoveryRequestMethod | requestType
| ) |  | `[signal]`

This signal is emitted when a discovery request is received.

Parameters:

  msg | specifies the received discovery request message.
  source | specifies the location where the message came.
  requestType | specifies the type of the incoming discovery request.

void discoveryResponseReceived | ( | const Herqq::Upnp::HDiscoveryResponse & | msg,
|  | const Herqq::Upnp::HEndpoint & | source
| ) |  | `[signal]`

This signal is emitted when a discovery response is received.

Parameters:

  msg | specifies the received discovery response message.
  source | specifies the location where the message came.

void resourceAvailableReceived | ( | const Herqq::Upnp::HResourceAvailable & | msg,
|  | const Herqq::Upnp::HEndpoint & | source
| ) |  | `[signal]`

This signal is emitted when a device announcement is received.

Parameters:

  msg | specifies the device announcement message.
  source | specifies the location where the message came.

void deviceUpdateReceived | ( | const Herqq::Upnp::HResourceUpdate & | msg,
|  | const Herqq::Upnp::HEndpoint & | source
| ) |  | `[signal]`

This signal is emitted when a device update is received.

Parameters:

  msg | specifies the device update message.
  source | specifies the location where the message came.

void resourceUnavailableReceived | ( | const Herqq::Upnp::HResourceUnavailable & | msg,
|  | const Herqq::Upnp::HEndpoint & | source
| ) |  | `[signal]`

This signal is emitted when a device announcement is received.

Parameters:

  msg | specifies the device announcement message.
  source | specifies the location where the message came.