Changeset 55:a8cda961ee7e for wokkel/client.py
- Timestamp:
- Apr 22, 2009, 4:50:28 PM (13 years ago)
- Branch:
- default
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@167
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/client.py
r42 r55 12 12 13 13 from twisted.application import service 14 from twisted.internet import defer, protocol,reactor14 from twisted.internet import reactor 15 15 from twisted.names.srvconnect import SRVConnector 16 16 from twisted.words.protocols.jabber import client, sasl, xmlstream 17 17 18 try: 19 from twisted.words.xish.xmlstream import BootstrapMixin 20 except ImportError: 21 from wokkel.compat import BootstrapMixin 22 23 from wokkel.subprotocols import StreamManager, XMPPHandler 18 from wokkel import generic 19 from wokkel.subprotocols import StreamManager 24 20 25 21 class CheckAuthInitializer(object): … … 128 124 129 125 130 class DeferredClientFactory(BootstrapMixin, protocol.ClientFactory): 131 protocol = xmlstream.XmlStream 126 class DeferredClientFactory(generic.DeferredXmlStreamFactory): 132 127 133 128 def __init__(self, jid, password): 134 BootstrapMixin.__init__(self) 135 136 self.jid = jid 137 self.password = password 138 139 deferred = defer.Deferred() 140 self.deferred = deferred 141 self.addBootstrap(xmlstream.INIT_FAILED_EVENT, deferred.errback) 142 143 class ConnectionInitializedHandler(XMPPHandler): 144 def connectionInitialized(self): 145 deferred.callback(None) 146 147 self.streamManager = StreamManager(self) 148 self.addHandler(ConnectionInitializedHandler()) 149 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 165 def clientConnectionFailed(self, connector, reason): 166 self.deferred.errback(reason) 129 authenticator = client.XMPPAuthenticator(jid, password) 130 generic.DeferredXmlStreamFactory.__init__(self, authenticator) 167 131 168 132 … … 181 145 182 146 147 183 148 def clientCreator(factory): 184 domain = factory. jid.host149 domain = factory.authenticator.jid.host 185 150 c = SRVConnector(reactor, 'xmpp-client', domain, factory) 186 151 c.connect()
Note: See TracChangeset
for help on using the changeset viewer.