Package brisa :: Package upnp :: Module ssdp :: Class SSDPServer
[hide private]
[frames] | no frames]

Class SSDPServer

source code

object --+
         |
        SSDPServer

Implementation of a SSDP server.

The notify_received and search_received methods are called when the appropriate type of datagram is received by the server.

Instance Methods [hide private]
 
__init__(self, server_name, xml_description_filename, max_age=1800, receive_notify=True)
Constructor for the SSDPServer class.
source code
 
is_running(self)
Returns True if the SSDPServer is running, False otherwise.
source code
 
start(self)
Starts the SSDPServer.
source code
 
stop(self)
Sends bye bye notifications and stops the SSDPServer.
source code
 
destroy(self)
Destroys the SSDPServer.
source code
 
clear_device_list(self)
Clears the device list.
source code
 
discovered_device_failed(self, dev)
Device could not be fully built, so forget it.
source code
boolean
is_known_device(self, usn)
Returns if the device with the passed usn is already known.
source code
 
subscribe(self, name, callback)
Subscribes a callback for an event.
source code
 
unsubscribe(self, name, callback)
Unsubscribes a callback for an event.
source code
 
announce_device(self)
Announces the device.
source code
 
register_device(self, device)
Registers a device on the SSDP server.
source code
 
_datagram_received(self, data, (host, port))
Handles a received multicast datagram.
source code
 
_discovery_request(self, headers, (host, port))
Processes discovery requests and responds accordingly.
source code
 
_notify_received(self, headers, (host, port))
Processes a presence announcement.
source code
 
_register(self, usn, st, location, server, cache_control, where='remote')
Registers a service or device.
source code
 
_local_register(self, usn, st, location, server, cache_control)
Registers locally a new service or device.
source code
 
_register_device(self, device) source code
 
_renew_notifications(self)
Renew notifications (sends a notify
source code
 
_unregister(self, usn) source code
 
_do_notify(self, usn)
Do a notification for the usn specified.
source code
 
_do_byebye(self, usn)
Do byebye notification for the usn specified.
source code
 
_callback(self, name, *args)
Performs callbacks for events.
source code
 
_cleanup(self)
Cleans the SSDPServer by removing known devices and internal cache.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  msg_already_started = 'tried to start() SSDPServer when alread...
  msg_already_stopped = 'tried to stop() SSDPServer when already...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, server_name, xml_description_filename, max_age=1800, receive_notify=True)
(Constructor)

source code 

Constructor for the SSDPServer class.

Parameters:
  • server_name (string) - server name
  • xml_description_filename () - XML description filename
  • max_age (integer) - max age parameter, default 1800.
  • receive_notify (boolean) - if False, ignores notify messages
Overrides: object.__init__

is_known_device(self, usn)

source code 

Returns if the device with the passed usn is already known.

Parameters:
  • usn (string) - device's usn
Returns: boolean
True if it is known

subscribe(self, name, callback)

source code 

Subscribes a callback for an event.

Parameters:
  • name (string) - name of the event. May be "new_device_event" or "removed_device_event"
  • callback (callable) - callback

unsubscribe(self, name, callback)

source code 

Unsubscribes a callback for an event.

Parameters:
  • name (string) - name of the event
  • callback (callable) - callback

register_device(self, device)

source code 

Registers a device on the SSDP server.

Parameters:
  • device (Device) - device to be registered

_datagram_received(self, data, (host, port))

source code 

Handles a received multicast datagram.

Parameters:
  • data (string) - raw data
  • host (string) - datagram source host
  • port (integer) - datagram source port

_discovery_request(self, headers, (host, port))

source code 

Processes discovery requests and responds accordingly.

Parameters:
  • headers (dictionary) - discovery headers
  • host (string @type port integer) - discovery source host
  • port - discovery source port

_notify_received(self, headers, (host, port))

source code 

Processes a presence announcement.

Parameters:
  • headers (dictionary) - notify headers
  • host (string) - notify source host
  • port (integer) - notify source port

_register(self, usn, st, location, server, cache_control, where='remote')

source code 

Registers a service or device.

Parameters:
  • usn (string) - usn
  • st (string) - st
  • location (string) - location
  • server (string) - server
  • cache_control (string) - cache control

Note: these parameters are part of the UPnP Specification. Even though they're abstracted by the framework (devices and services messages already contain these parameters), if you want to understand it please refer to the UPnP specification. Links can be found at our developer documentation homepage.

_do_notify(self, usn)

source code 

Do a notification for the usn specified.

Parameters:
  • usn (string) - st

_do_byebye(self, usn)

source code 

Do byebye notification for the usn specified.

Parameters:
  • usn (string) - usn

Class Variable Details [hide private]

msg_already_started

Value:
'tried to start() SSDPServer when already started'

msg_already_stopped

Value:
'tried to stop() SSDPServer when already stopped'