Ignore:
Timestamp:
Oct 10, 2008, 4:35:43 PM (14 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@88
Message:

Backport XmlStreamServerFactory?.

Author: ralphm.
Fixes #29.

This also replaces XmlStreamFactoryMixin? with BootstrapMixin? for DeferredClientFactory?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/client.py

    r14 r34  
    1717
    1818try:
    19     from twisted.words.xish.xmlstream import XmlStreamFactoryMixin
     19    from twisted.words.xish.xmlstream import BootstrapMixin
    2020except ImportError:
    21     from wokkel.compat import XmlStreamFactoryMixin
     21    from wokkel.compat import BootstrapMixin
    2222
    2323from wokkel.subprotocols import StreamManager, XMPPHandler
     
    128128
    129129
    130 class DeferredClientFactory(XmlStreamFactoryMixin, protocol.ClientFactory):
     130class DeferredClientFactory(BootstrapMixin, protocol.ClientFactory):
    131131    protocol = xmlstream.XmlStream
    132132
    133133    def __init__(self, jid, password):
    134         self.authenticator = client.XMPPAuthenticator(jid, password)
    135         XmlStreamFactoryMixin.__init__(self, self.authenticator)
     134        BootstrapMixin.__init__(self)
     135
     136        self.jid = jid
     137        self.password = password
    136138
    137139        deferred = defer.Deferred()
    138140        self.deferred = deferred
    139 
    140141        self.addBootstrap(xmlstream.INIT_FAILED_EVENT, deferred.errback)
    141142
     
    147148        self.addHandler(ConnectionInitializedHandler())
    148149
     150
     151    def buildProtocol(self, addr):
     152        """
     153        Create an instance of XmlStream.
     154
     155        A new authenticator instance will be created and passed to the new
     156        XmlStream. Registered bootstrap event observers are installed as well.
     157        """
     158        self.authenticator = client.XMPPAuthenticator(self.jid, self.password)
     159        xs = self.protocol(self.authenticator)
     160        xs.factory = self
     161        self.installBootstraps(xs)
     162        return xs
     163
     164
    149165    def clientConnectionFailed(self, connector, reason):
    150166        self.deferred.errback(reason)
     167
    151168
    152169    def addHandler(self, handler):
     
    155172        """
    156173        self.streamManager.addHandler(handler)
     174
    157175
    158176    def removeHandler(self, handler):
Note: See TracChangeset for help on using the changeset viewer.