From c2f6f077762282d311a6f876f94cc1a4eb9e805f Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 20 Jul 2014 20:46:03 +0200 Subject: 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. --- slixmpp/features/feature_bind/bind.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'slixmpp/features/feature_bind/bind.py') diff --git a/slixmpp/features/feature_bind/bind.py b/slixmpp/features/feature_bind/bind.py index ac69ee77..f636abf9 100644 --- a/slixmpp/features/feature_bind/bind.py +++ b/slixmpp/features/feature_bind/bind.py @@ -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() -- cgit v1.2.3