Changeset 35:2866eaae775f in ralphm-patches


Ignore:
Timestamp:
Feb 12, 2010, 12:01:52 PM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Minor cleanups to deal with changed APIs

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • client_service_example.patch

    r34 r35  
    1 diff -r a0bcf2e586ec doc/examples/client_service.tac
     1diff -r 0a3d1655a3e5 doc/examples/client_service.tac
    22--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
    3 +++ b/doc/examples/client_service.tac   Fri Feb 12 09:50:08 2010 +0100
    4 @@ -0,0 +1,40 @@
     3+++ b/doc/examples/client_service.tac   Fri Feb 12 11:55:08 2010 +0100
     4@@ -0,0 +1,41 @@
    55+from twisted.application import service
    66+from twisted.internet import defer
     
    88+from wokkel.client import ClientService
    99+from wokkel.generic import FallbackHandler
    10 +from wokkel.xmppim import RosterProtocol
     10+from wokkel.xmppim import RosterServerProtocol
    1111+
    1212+import socket
    1313+domain = socket.gethostname()
    1414+
    15 +class StaticRoster(RosterProtocol):
     15+class StaticRoster(RosterServerProtocol):
    1616+
    1717+    def __init__(self):
     18+        RosterServerProtocol.__init__(self)
    1819+        self.roster = {'ralphm':
    1920+                           [{'jid': 'intosi@' + domain,
     
    4041+clientService = ClientService(domain, 5224)
    4142+clientService.logTraffic = True
    42 +clientService.addHandler(FallbackHandler())
    43 +clientService.addHandler(StaticRoster())
     43+FallbackHandler().setHandlerParent(clientService)
     44+StaticRoster().setHandlerParent(clientService)
    4445+clientService.setServiceParent(application)
  • xmpp_client_service.patch

    r34 r35  
    11diff -r 67a42d8a1c73 wokkel/client.py
    22--- a/wokkel/client.py  Fri Feb 12 09:31:19 2010 +0100
    3 +++ b/wokkel/client.py  Fri Feb 12 09:37:28 2010 +0100
    4 @@ -18,10 +18,11 @@
     3+++ b/wokkel/client.py  Fri Feb 12 11:46:41 2010 +0100
     4@@ -17,11 +17,12 @@
     5 from twisted.names.srvconnect import SRVConnector
    56 from twisted.python import log
    67 from twisted.words.protocols.jabber import client, error, sasl, xmlstream
    7  from twisted.words.protocols.jabber.jid import internJID as JID
     8-from twisted.words.protocols.jabber.jid import internJID as JID
    89-from twisted.words.xish import domish
     10+from twisted.words.protocols.jabber.jid import JID, internJID
    911+from twisted.words.xish import domish, utility
    1012 
     
    1214-from wokkel.subprotocols import StreamManager
    1315+from wokkel.compat import XmlStreamServerFactory
    14 +from wokkel.subprotocols import StreamManager, XMPPHandlerContainer
     16+from wokkel.subprotocols import StreamManager, XMPPHandlerCollection
    1517 
    1618 NS_CLIENT = 'jabber:client'
    1719 
    18 @@ -350,3 +351,130 @@
     20@@ -350,3 +351,132 @@
    1921             reply['id'] = iq['id']
    2022         reply.addElement((client.NS_XMPP_SESSION, 'session'))
     
    4446+
    4547+
    46 +class ClientService(XMPPHandlerContainer, service.Service):
     48+class ClientService(XMPPHandlerCollection, service.Service):
    4749+    """
    4850+    Service for accepting XMPP client connections.
     
    5860+    makes it easier to create adapters.
    5961+
    60 +    As an L{xmlstream.XMPPHandlerContainer}, this service creates a fake XML
     62+    As an L{xmlstream.XMPPHandlerCollection}, this service creates a fake XML
    6163+    stream that is passed to the XMPP subprotocol handlers. The received
    6264+    stanzas from the incoming client connections are passed on to the handlers
     
    7274+        self.port = port
    7375+
    74 +        self.factory = XmlStreamServerFactory(XMPPClientListenAuthenticator,
    75 +                                              self.domain)
     76+        def authenticatorFactory():
     77+            return XMPPClientListenAuthenticator(self.domain)
     78+
     79+        self.factory = XmlStreamServerFactory(authenticatorFactory)
    7680+        self.factory.addBootstrap(xmlstream.STREAM_CONNECTED_EVENT,
    7781+                                  self.makeConnection)
     
    8185+        self.streams = {}
    8286+
    83 +        XMPPHandlerContainer.__init__(self)
     87+        XMPPHandlerCollection.__init__(self)
    8488+
    8589+
     
    141145+        """
    142146+
    143 +        destination = JID(element["to"]).full()
     147+        destination = internJID(element["to"]).full()
    144148+
    145149+        if destination not in self.streams:
Note: See TracChangeset for help on using the changeset viewer.