Make xmlstream use an asyncio loop

Scheduled events, connection, TLS handshake (with STARTTLS), read and write
on the socket are all done using only asyncio.

A lot of threads, and thread-related (and thus useless) things still remain.
This is only a first step.
This commit is contained in:
Florent Le Coz
2014-07-20 20:46:03 +02:00
parent 5ab77c7452
commit c2f6f07776
9 changed files with 217 additions and 1003 deletions

View File

@@ -42,13 +42,16 @@ class FeatureBind(BasePlugin):
features -- The stream features stanza.
"""
log.debug("Requesting resource: %s", self.xmpp.requested_jid.resource)
self.features = features
iq = self.xmpp.Iq()
iq['type'] = 'set'
iq.enable('bind')
if self.xmpp.requested_jid.resource:
iq['bind']['resource'] = self.xmpp.requested_jid.resource
response = iq.send(now=True)
iq.send(block=False, callback=self._on_bind_response)
def _on_bind_response(self, response):
self.xmpp.boundjid = JID(response['bind']['jid'], cache_lock=True)
self.xmpp.bound = True
self.xmpp.event('session_bind', self.xmpp.boundjid, direct=True)
@@ -58,7 +61,7 @@ class FeatureBind(BasePlugin):
log.info("JID set to: %s", self.xmpp.boundjid.full)
if 'session' not in features['features']:
if 'session' not in self.features['features']:
log.debug("Established Session")
self.xmpp.sessionstarted = True
self.xmpp.session_started_event.set()