summaryrefslogtreecommitdiff
path: root/slixmpp/features
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-07-20 20:46:03 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-07-20 20:46:03 +0200
commitc2f6f077762282d311a6f876f94cc1a4eb9e805f (patch)
tree935725c968da27ea1713617fa6fffcf2edbdc299 /slixmpp/features
parent5ab77c745270d7d5c016c1dc7ef2a82533a4b16e (diff)
downloadslixmpp-c2f6f077762282d311a6f876f94cc1a4eb9e805f.tar.gz
slixmpp-c2f6f077762282d311a6f876f94cc1a4eb9e805f.tar.bz2
slixmpp-c2f6f077762282d311a6f876f94cc1a4eb9e805f.tar.xz
slixmpp-c2f6f077762282d311a6f876f94cc1a4eb9e805f.zip
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.
Diffstat (limited to 'slixmpp/features')
-rw-r--r--slixmpp/features/feature_bind/bind.py7
-rw-r--r--slixmpp/features/feature_mechanisms/mechanisms.py4
-rw-r--r--slixmpp/features/feature_session/session.py3
-rw-r--r--slixmpp/features/feature_starttls/starttls.py3
4 files changed, 11 insertions, 6 deletions
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()
diff --git a/slixmpp/features/feature_mechanisms/mechanisms.py b/slixmpp/features/feature_mechanisms/mechanisms.py
index 663bfe57..3cbb83f2 100644
--- a/slixmpp/features/feature_mechanisms/mechanisms.py
+++ b/slixmpp/features/feature_mechanisms/mechanisms.py
@@ -233,7 +233,9 @@ class FeatureMechanisms(BasePlugin):
self.xmpp.authenticated = True
self.xmpp.features.add('mechanisms')
self.xmpp.event('auth_success', stanza, direct=True)
- raise RestartStream()
+ # Restart the stream
+ self.xmpp.init_parser()
+ self.xmpp.send_raw(self.xmpp.stream_header)
def _handle_fail(self, stanza):
"""SASL authentication failed. Disconnect and shutdown."""
diff --git a/slixmpp/features/feature_session/session.py b/slixmpp/features/feature_session/session.py
index c2694a9f..08f7480f 100644
--- a/slixmpp/features/feature_session/session.py
+++ b/slixmpp/features/feature_session/session.py
@@ -44,8 +44,9 @@ class FeatureSession(BasePlugin):
iq = self.xmpp.Iq()
iq['type'] = 'set'
iq.enable('session')
- iq.send(now=True)
+ iq.send(block=False, callback=self._on_start_session_response)
+ def _on_start_session_response(self, response):
self.xmpp.features.add('session')
log.debug("Established Session")
diff --git a/slixmpp/features/feature_starttls/starttls.py b/slixmpp/features/feature_starttls/starttls.py
index 4b9dd60b..a05f755b 100644
--- a/slixmpp/features/feature_starttls/starttls.py
+++ b/slixmpp/features/feature_starttls/starttls.py
@@ -52,7 +52,7 @@ class FeatureSTARTTLS(BasePlugin):
# We have already negotiated TLS, but the server is
# offering it again, against spec.
return False
- elif not self.xmpp.use_tls:
+ elif self.xmpp.disable_starttls:
return False
else:
self.xmpp.send(features['starttls'], now=True)
@@ -63,4 +63,3 @@ class FeatureSTARTTLS(BasePlugin):
log.debug("Starting TLS")
if self.xmpp.start_tls():
self.xmpp.features.add('starttls')
- raise RestartStream()