yell

Core SSDP services, message types, and encoding/decoding functions Generate a discovery reply message for a service

Types

An SSDP message received from the network. Can be a discovery request, a discovery reply, or a notification. Access message contents with functions like search_target() and notification_status().

pub opaque type Message

A service that can be advertised on the network. Create with new_service() and configure with with_location(), max_age(), and with_header().

pub opaque type Service

The subtype of an SSDP notification message.

  • Alive - Service is starting up
  • Update - Service configuration has changed
  • ByeBye - Service is shutting down
pub type Status {
  Alive
  Update
  ByeBye
}

Constructors

  • Alive
  • Update
  • ByeBye

Values

pub fn decode_message(content: BitArray) -> Result(Message, Nil)

Parse a received SSDP datagram as a Message

pub fn encode_discovery(
  search: uri.Uri,
  max_wait: Int,
  headers: List(#(String, String)),
) -> BitArray

Generate a discovery message (for internal use)

pub fn encode_notification(
  service: Service,
  status: Status,
) -> BitArray

Generate a notification message from a service (for internal use)

pub fn encode_reply(service: Service) -> BitArray

Generate a reply for a service (for internal use)

pub fn is_discovery(message: Message) -> Bool

Return True if the message is a discovery request.

pub fn is_match(service: Service, search_term: uri.Uri) -> Bool

Check if a service matches a discovery search term. Returns True if the search term is “ssdp:all” or matches the service’s type.

pub fn max_age(service: Service, max_age: Int) -> Service

Configure the maximum time (in seconds) receivers should cache messages about this service. Typical values are 1800 (30 minutes) or 3600 (1 hour).

pub fn new_service(
  service_type: String,
  usn: String,
) -> Result(Service, Nil)

Create a new SSDP service to advertise. service_type is a URI for the type of service provided, and usn is a URI with a unique name for the service. Returns an error if either of these strings fails to parse to a URI.

pub fn notification_status(
  message: Message,
) -> Result(Status, Nil)

Extract the Status from a notification message. Returns an error if the message is not a notification.

pub fn search_target(message: Message) -> Result(uri.Uri, Nil)

Extract the search target from a discovery message. Returns an error if the message is not a discovery request.

pub const ssdp_multicast: String
pub const ssdp_port: Int
pub fn with_header(
  service: Service,
  key: String,
  value: String,
) -> Service

Add a custom HTTP header to the messages sent by this service.

pub fn with_location(service: Service, loc: String) -> Service

Configure the location of the service. Typically a URL.

Search Document