summaryrefslogtreecommitdiff
path: root/slixmpp/features
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2016-05-28 14:46:39 +0200
committermathieui <mathieui@mathieui.net>2016-05-28 14:46:39 +0200
commit49054070922958141808c48e9204cd5cdf6ca164 (patch)
tree0f6164482dee03341d535ad71ff2a7d51a0d7e6c /slixmpp/features
parentbd6ec1093907b5922199be490cc06d802aa224fd (diff)
downloadslixmpp-49054070922958141808c48e9204cd5cdf6ca164.tar.gz
slixmpp-49054070922958141808c48e9204cd5cdf6ca164.tar.bz2
slixmpp-49054070922958141808c48e9204cd5cdf6ca164.tar.xz
slixmpp-49054070922958141808c48e9204cd5cdf6ca164.zip
Fix the ordering of stream features
since iq.send is non-blocking, some features handlers could end up being executed before others were set, leading to issues. Adding yield from where it’s necessary fixes that.
Diffstat (limited to 'slixmpp/features')
-rw-r--r--slixmpp/features/feature_bind/bind.py4
-rw-r--r--slixmpp/features/feature_session/session.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/slixmpp/features/feature_bind/bind.py b/slixmpp/features/feature_bind/bind.py
index c031ab72..e837ee0a 100644
--- a/slixmpp/features/feature_bind/bind.py
+++ b/slixmpp/features/feature_bind/bind.py
@@ -6,6 +6,7 @@
See the file LICENSE for copying permission.
"""
+import asyncio
import logging
from slixmpp.jid import JID
@@ -34,6 +35,7 @@ class FeatureBind(BasePlugin):
register_stanza_plugin(Iq, stanza.Bind)
register_stanza_plugin(StreamFeatures, stanza.Bind)
+ @asyncio.coroutine
def _handle_bind_resource(self, features):
"""
Handle requesting a specific resource.
@@ -49,7 +51,7 @@ class FeatureBind(BasePlugin):
if self.xmpp.requested_jid.resource:
iq['bind']['resource'] = self.xmpp.requested_jid.resource
- iq.send(callback=self._on_bind_response)
+ yield from iq.send(callback=self._on_bind_response)
def _on_bind_response(self, response):
self.xmpp.boundjid = JID(response['bind']['jid'])
diff --git a/slixmpp/features/feature_session/session.py b/slixmpp/features/feature_session/session.py
index 0635455a..2f9548eb 100644
--- a/slixmpp/features/feature_session/session.py
+++ b/slixmpp/features/feature_session/session.py
@@ -6,6 +6,7 @@
See the file LICENSE for copying permission.
"""
+import asyncio
import logging
from slixmpp.stanza import Iq, StreamFeatures
@@ -34,6 +35,7 @@ class FeatureSession(BasePlugin):
register_stanza_plugin(Iq, stanza.Session)
register_stanza_plugin(StreamFeatures, stanza.Session)
+ @asyncio.coroutine
def _handle_start_session(self, features):
"""
Handle the start of the session.
@@ -44,7 +46,7 @@ class FeatureSession(BasePlugin):
iq = self.xmpp.Iq()
iq['type'] = 'set'
iq.enable('session')
- iq.send(callback=self._on_start_session_response)
+ yield from iq.send(callback=self._on_start_session_response)
def _on_start_session_response(self, response):
self.xmpp.features.add('session')