4. ssdp — SSDP Server implementation
python-brisa provides a SSDP (Simple Service Discovery
Protocol) module which can be used on
the control point’s side or on the device’s.
- Device’s side - Used for annoucing the device, its embedded devices and all services.
- Control Point’s side - Used for keeping record of known devices.
There’s no need to use the SSDP Server directly when using the control point or
device API’s.
4.1. SSDPServer class
Implementation of a SSDP Server.
4.1.1. Attributes
The attribute of the SSDPServer class are:
- server_name - name of the server.
- xml_description_filename - XML description filename.
- max_age - max age parameter, default is 1800.
- receive_notify - if False, ignores notify messages.
- known_devices - dict of the known devices.
- advertised - dict of the advertised devices.
- _callbacks - dict of the callbacks.
4.1.2. Methods
-
is_running()
- Returns True if the SSDPServer is running, False otherwise.
-
start()
- Starts the SSDPServer.
-
stop()
- Sends bye bye notifications and stops the SSDPServer.
-
destroy()
- Destroys the SSDPServer.
-
clear_device_list()
- Clears the device list.
-
discovered_device_failed(dev)
- Device could not be fully built, so forget it.
-
is_known_device(usn)
- Returns if the device with the passed usn is already known.
-
subscribe(name, callback)
- Subscribes a callback for an given name event.
-
unsubscribe(name, callback)
- Unsubscribes a call back for an event.
-
announce_device()
- Announces the device.
-
register_device(device)
- Registers a device on the SSDP Server.
-
_datagram_received(data, (host, pot))
- Handles a received multicast datagram.
-
_discovery_request(headers, (host, port))
- Processes the discovery requests and responds accordingly.
-
_notify_received(headers, (host, port))
- Processes a presence announcement.
-
_register(usn, st, location, server, cache_control, where='remote')
- Registers a service or device.
-
_local_register(usn, st, location, server, cache_control)
- Registers locally a new service or device.
-
_register_device(device)
- Registers a device.
-
_renew_notifications()
- Renew notifications (sends a notify).
-
_unregister(usn)
- Unregisters a device.
-
_do_notify(usn)
- Do a notification for the usn specified.
-
_do_byebye(usn)
- Do byebye notification for the usn specified.
-
_callback(name, *args)
- Performs callbacks for events.
-
_cleanup()
- Cleans the SSDPServer by removing known devices and internal cache.