Changeset 65:6936acbdb9bd


Ignore:
Timestamp:
Jul 8, 2009, 10:05:58 PM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@183
Message:

Add support for the XMPP Ping protocol.

Author: ralphm
Fixes #55.

This adds a whole bunch of examples around the ping protocol in different
settings for both the pinger and pingee: as a external server-side component,
as a standalone server with server-to-server connectivity and as a client.

Also updates the disco support to allow for non-deferred responses from
subprotocol handlers

Files:
10 added
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/disco.py

    r63 r65  
    539539        @rtype: L{defer.Deferred}
    540540        """
    541         dl = [handler.getDiscoInfo(requestor, target, nodeIdentifier)
     541        dl = [defer.maybeDeferred(handler.getDiscoInfo, requestor, target,
     542                                                        nodeIdentifier)
    542543              for handler in self.parent
    543544              if IDisco.providedBy(handler)]
     
    561562        @rtype: L{defer.Deferred}
    562563        """
    563         dl = [handler.getDiscoItems(requestor, target, nodeIdentifier)
     564        dl = [defer.maybeDeferred(handler.getDiscoItems, requestor, target,
     565                                                         nodeIdentifier)
    564566              for handler in self.parent
    565567              if IDisco.providedBy(handler)]
  • wokkel/test/test_disco.py

    r63 r65  
    752752
    753753
     754    def test_infoNotDeferred(self):
     755        """
     756        C{info} should gather disco info from sibling handlers.
     757        """
     758        discoItems = [disco.DiscoIdentity('dummy', 'generic',
     759                                          'Generic Dummy Entity'),
     760                      disco.DiscoFeature('jabber:iq:version')
     761        ]
     762
     763        class DiscoResponder(XMPPHandler):
     764            implements(disco.IDisco)
     765
     766            def getDiscoInfo(self, requestor, target, nodeIdentifier):
     767                if not nodeIdentifier:
     768                    return discoItems
     769                else:
     770                    return []
     771
     772        def cb(result):
     773            self.assertEquals(discoItems, result)
     774
     775        self.service.parent = [self.service, DiscoResponder()]
     776        d = self.service.info(JID('test@example.com'), JID('example.com'), '')
     777        d.addCallback(cb)
     778        return d
     779
     780
    754781    def test_items(self):
    755782        """
     
    774801        d.addCallback(cb)
    775802        return d
     803
     804
     805    def test_itemsNotDeferred(self):
     806        """
     807        C{info} should also collect results not returned via a deferred.
     808        """
     809        discoItems = [disco.DiscoItem(JID('example.com'), 'test', 'Test node')]
     810
     811        class DiscoResponder(XMPPHandler):
     812            implements(disco.IDisco)
     813
     814            def getDiscoItems(self, requestor, target, nodeIdentifier):
     815                if not nodeIdentifier:
     816                    return discoItems
     817                else:
     818                    return []
     819
     820        def cb(result):
     821            self.assertEquals(discoItems, result)
     822
     823        self.service.parent = [self.service, DiscoResponder()]
     824        d = self.service.items(JID('test@example.com'), JID('example.com'), '')
     825        d.addCallback(cb)
     826        return d
Note: See TracChangeset for help on using the changeset viewer.