Sise (Sise v0.9.2) View Source

Sise is a library that implements the simple service discovery protocol (SSDP).

Sise will listen on the network for announcements of available UPnP devices and services. Additionally it will send out search requests from time to time. All discovered devices will be stored by Sise.

A client of this library can either fetch the discoveries or subscribe for notifications (on subscription the listener will be called with the already discovered devices/services).

Sise implements the Application behaviour and thus will start itself with detecting devices and service.

Link to this section Summary

Types

SSDP's "notification type" (aka device or service others might need)

Functions

Get discovered device and service information

Subscribe to receive notifications about discoveries

Unsubscribe from notifications about discoveries.

Link to this section Types

Specs

nt() :: :all | String.t()

SSDP's "notification type" (aka device or service others might need)

This type is used as a parameter to select the 'notification type' the caller is interested in.

If atom :all is given the client will get all of the discoveries. Whereas if a string is given it is interpreted as the exact notification type as given by the peer.

Examples for UPnP notification types are "upnp:rootdevice" or "urn:schemas-upnp-org:service:SwitchPower:1".

Link to this section Functions

Specs

get(nt()) :: [Sise.Discovery.t()]

Get discovered device and service information

Call this function to get information about discovered devices and services.

Link to this function

subscribe(notification_type)

View Source

Specs

subscribe(nt()) :: nil

Subscribe to receive notifications about discoveries

When calling this function, the caller will

  • receive a notification message of type :ssdp_add for every already known discovery
  • receive a message for every change in the future

It is possible to subscribe to multiple different notification types.

The possible notification messages to be received are these:

{:ssdp_add, Sise.Discovery.t()}

This message informs that a new device or service has been discovered. It will contain a struct with all available information on the discovery.

{:ssdp_update, Sise.Discovery.t(), [{atom(), String.t(), String.t()}]}

Informs the listener that the available information about a known device/service has changed. The message will carry the new version of the Discovery struct. It will also carry a list with the differences between the old and the new device/service information.

{:ssdp_delete, Sise.Discovery.t()}

Informs that a device/service is no longer available. The message will carry the last known version of the Discovery struct. See also Sise.Discovery.diff/2.

Link to this function

unsubscribe(notification_type)

View Source

Specs

unsubscribe(nt()) :: nil

Unsubscribe from notifications about discoveries.

Note that the notification mechanism does a very simple matching for notification types. If you subscribe to multiple concrete services/devices and then unsubscribe(:all), they will all be removed. However if you subscribe to :all services/devices and then unsubscribe from a concrete one you will still get all notifications.