coherence.upnp.core.event (module)¶
Events¶
This module contains several classes related to UPnP events.
EventServer
¶
A class inherited from twisted.web.resource.Resource
representing an
event’s server with dispatch events capabilities via EventsDispatcher.
EventSubscriptionServer
¶
This class is the server part on the device side. It listens to subscribe requests and registering the subscriber to send event messages to the device.
EventProtocol
¶
The Event’s Protocol.
NotificationProtocol
¶
The Notification protocol used to by send_notification()
.
-
class
EventServer
(control_point)[source]¶ Bases:
eventdispatcher.eventdispatcher.EventDispatcher
,twisted.web.resource.Resource
,coherence.log.LogAble
-
Changed in version 0.9.0:
Migrated from louie/dispatcher to EventDispatcher
The emitted events changed:
UPnP.Event.Server.message_received => event_server_message_received
-
logCategory
= 'event_server'¶
-
class
EventSubscriptionServer
(service)[source]¶ Bases:
eventdispatcher.eventdispatcher.EventDispatcher
,twisted.web.resource.Resource
,coherence.log.LogAble
This class is the server part on the device side. It listens to subscribe requests and registers the subscriber to send event messages to this device. If an unsubscribe request is received, the subscription is cancelled and no more event messages will be sent.
we receive a subscription request like:
{'callback': '<http://192.168.213.130:9083/BYvZMzfTSQkjHwzOThaP/ConnectionManager>', 'host': '192.168.213.107:30020', 'nt': 'upnp:event', 'content-length': '0', 'timeout': 'Second-300'}
modify the callback value:
callback = callback[1:len(callback)-1]
and pack it into a subscriber dict:
{'uuid:oAQbxiNlyYojCAdznJnC': { 'callback': '<http://192.168.213.130:9083/BYvZMzfTSQkjHwzOThaP/ConnectionManager>', 'created': 1162374189.257338, 'timeout': 'Second-300', 'sid': 'uuid:oAQbxiNlyYojCAdznJnC'}}
-
Changed in version 0.9.0:
Migrated from louie/dispatcher to EventDispatcher
The emitted events changed:
UPnP.Event.Client.message_received => event_client_message_received
-
logCategory
= 'event_subscription_server'¶
-
class
Event
(sid, elements=None, raw=None)[source]¶ Bases:
dict
,coherence.log.LogAble
-
logCategory
= 'event'¶
-
ns
= 'urn:schemas-upnp-org:event-1-0'¶
-
-
class
EventProtocol
(service, action)[source]¶ Bases:
twisted.internet.protocol.Protocol
,coherence.log.LogAble
-
logCategory
= 'event_protocol'¶
-
connectionMade
()[source]¶ Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
-
dataReceived
(data)[source]¶ Called whenever data is received.
Use this method to translate to a higher-level message. Usually, some callback will be made upon the receipt of each complete protocol message.
- @param data: a string of indeterminate length. Please keep in mind
that you will probably need to buffer some data, as partial (or multiple) protocol messages may be received! I recommend that unit tests for protocols call through to this method with differing chunk sizes, down to one byte at a time.
-
-
subscribe
(service, action='subscribe')[source]¶ send a subscribe/renewal/unsubscribe request to a service return the device response
-
class
NotificationProtocol
[source]¶ Bases:
twisted.internet.protocol.Protocol
,coherence.log.LogAble
-
logCategory
= 'notification_protocol'¶
-
connectionMade
()[source]¶ Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
-
dataReceived
(data)[source]¶ Called whenever data is received.
Use this method to translate to a higher-level message. Usually, some callback will be made upon the receipt of each complete protocol message.
- @param data: a string of indeterminate length. Please keep in mind
that you will probably need to buffer some data, as partial (or multiple) protocol messages may be received! I recommend that unit tests for protocols call through to this method with differing chunk sizes, down to one byte at a time.
-