Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0060.py @ 2305:972e33507609
plugin XEP-0060: addManagedNode callbacks now use client syntax instead of profile
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 05 Jul 2017 15:04:43 +0200 |
parents | b5befe7722d3 |
children | 01f0a954d506 |
comparison
equal
deleted
inserted
replaced
2304:666ad9de044c | 2305:972e33507609 |
---|---|
186 """Add a handler for a node | 186 """Add a handler for a node |
187 | 187 |
188 @param node(unicode): node to monitor | 188 @param node(unicode): node to monitor |
189 all node *prefixed* with this one will be triggered | 189 all node *prefixed* with this one will be triggered |
190 @param **kwargs: method(s) to call when the node is found | 190 @param **kwargs: method(s) to call when the node is found |
191 the methode must be named after PubSub constants in lower case | 191 the method must be named after PubSub constants in lower case |
192 and suffixed with "_cb" | 192 and suffixed with "_cb" |
193 e.g.: "publish_cb" for C.PS_PUBLISH, "delete_cb" for C.PS_DELETE | 193 e.g.: "items_cb" for C.PS_ITEMS, "delete_cb" for C.PS_DELETE |
194 """ | 194 """ |
195 assert node is not None | 195 assert node is not None |
196 assert kwargs | 196 assert kwargs |
197 callbacks = self._node_cb.setdefault(node, {}) | 197 callbacks = self._node_cb.setdefault(node, {}) |
198 for event, cb in kwargs.iteritems(): | 198 for event, cb in kwargs.iteritems(): |
790 continue | 790 continue |
791 | 791 |
792 def itemsReceived(self, event): | 792 def itemsReceived(self, event): |
793 log.debug(u"Pubsub items received") | 793 log.debug(u"Pubsub items received") |
794 for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_ITEMS): | 794 for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_ITEMS): |
795 callback(event, self.parent.profile) | 795 callback(self.parent, event) |
796 | 796 |
797 def deleteReceived(self, event): | 797 def deleteReceived(self, event): |
798 log.debug((u"Publish node deleted")) | 798 log.debug((u"Publish node deleted")) |
799 for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_DELETE): | 799 for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_DELETE): |
800 callback(event, self.parent.profile) | 800 callback(self.parent, event) |
801 | 801 |
802 def subscriptions(self, service, nodeIdentifier, sender=None): | 802 def subscriptions(self, service, nodeIdentifier, sender=None): |
803 """Return the list of subscriptions to the given service and node. | 803 """Return the list of subscriptions to the given service and node. |
804 | 804 |
805 @param service: The publish subscribe service to retrieve the subscriptions from. | 805 @param service: The publish subscribe service to retrieve the subscriptions from. |