Changes between Version 2 and Version 3 of develop
- Timestamp:
- 2013-04-13 12:07:13 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
develop
v2 v3 37 37 After the '''SUBSCRIBE''' request succeeds, the plugin will have a subscription identifier (SID) ''sid'', and a duration in seconds ''timeout''. For the next ''timeout'' seconds, the UPnP device will send '''NOTIFY''' messages to the callback URL. 38 38 39 The plugin has an action '' VariableChanged'' in service ''pluginServiceId'' which accepts two parameters: ''valueParam'' (the new value of the varable), and ''sidParam'' (the subscription identifier). The plugin wants this action to be invoked by the proxy every time that ''UPnPVariable'' changes.39 The plugin has an action ''!VariableChanged'' in service ''pluginServiceId'' which accepts two parameters: ''valueParam'' (the new value of the varable), and ''sidParam'' (the subscription identifier). The plugin wants this action to be invoked by the proxy every time that ''UPnPVariable'' changes. 40 40 41 41 To register the subscription with the proxy, perform an HTTP '''PUT''' to /upnp/event/''sid'': … … 53 53 method = "PUT", 54 54 headers = { 55 ["Content-Type"] = "text/ html",55 ["Content-Type"] = "text/xml", 56 56 ["Content-Length"] = proxyRequestBody:len(), 57 57 }, … … 68 68 }}} 69 69 70 The proxy will soon receive (or may have already received) the initial UPnP '''NOTIFY''' (with sequence 0), and will invoke the '' VariableChanged'' action on the plugin.70 The proxy will soon receive (or may have already received) the initial UPnP '''NOTIFY''' (with sequence 0), and will invoke the ''!VariableChanged'' action on the plugin. 71 71 72 72 == Receiving an event notification from the proxy == 73 73 74 The plugin should have an action '' VariableChanged'', matching the ''serviceId'' and ''action'' parameters supplied in the previous section's sample code. In the74 The plugin should have an action ''!VariableChanged'', matching the ''serviceId'' and ''action'' parameters supplied in the previous section's sample code. In the 75 75 76 76 {{{ … … 120 120 == Avoiding deadlocks == 121 121 122 TODO 122 The proxy runs in a single thread. Consequently it is vital that plugins do not delay it when actions are invoked by the proxy, because it will prevent other plugins and UPnP devices from contacting the proxy. 123 124 To minimize the likelihood of delays, plugins should restrict their actions to a minimum during actions such as ''!VariableChanged''. The plugin should liberally use luup.call_delay() for anything that may block or take significant time to run. 125 126 Because the plugin makes HTTP requests to the proxy and the proxy makes action calls to the plugin, there is a risk of deadlock. To minimize this, the proxy will time out and retry after a random period of time from 1 to 5 seconds, up to a maximum of three times. If the action still cannot be delivered then it is discarded. It is a good idea for the plugin to do the same, using retry counters and luup.call_delay() to compartmentalize each invocation and allow the proxy to contact the plugin as soon as possible.