Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/nbxmpp
diff options
context:
space:
mode:
authorlovetox <philipp@hoerist.com>2020-03-20 23:06:06 +0300
committerlovetox <philipp@hoerist.com>2020-03-20 23:06:06 +0300
commitb22e79b68f4ff3c7bbfca260aa1663dd35b542bd (patch)
tree51caa845511a3aa9ad850fc2ee666f1b25b996e7 /nbxmpp
parent636ba000f923a0a03c8b069dc893ce992d62b142 (diff)
Client: Simplify bind/session error handling
Diffstat (limited to 'nbxmpp')
-rw-r--r--nbxmpp/client.py19
-rw-r--r--nbxmpp/const.py2
2 files changed, 6 insertions, 15 deletions
diff --git a/nbxmpp/client.py b/nbxmpp/client.py
index 115bdd7..ea86eac 100644
--- a/nbxmpp/client.py
+++ b/nbxmpp/client.py
@@ -638,9 +638,6 @@ class Client(Observable):
elif self.state == StreamState.WAIT_FOR_BIND:
self._on_bind(stanza)
- elif self.state == StreamState.BIND_FAILED:
- self._disconnect_with_error(StreamError.BIND, 'bind-failed')
-
elif self.state == StreamState.BIND_SUCCESSFUL:
self._smacks.send_enable()
self._dispatcher.set_dispatch_callback(None)
@@ -650,9 +647,6 @@ class Client(Observable):
elif self.state == StreamState.WAIT_FOR_SESSION:
self._on_session(stanza)
- elif self.state == StreamState.SESSION_FAILED:
- self._disconnect_with_error(StreamError.SESSION, 'session-failed')
-
elif self.state == StreamState.WAIT_FOR_RESUMED:
self._smacks.delegate(stanza)
@@ -735,12 +729,9 @@ class Client(Observable):
def _on_bind(self, stanza):
if not isResultNode(stanza):
- self._log.error('Binding failed: %s.', stanza.getTag('error'))
- if stanza.getError() == 'conflict' and self.resource is not None:
- self._log.info('Try to request server generated resource')
- self._start_bind()
- return
- self.set_state(StreamState.BIND_FAILED)
+ self._disconnect_with_error(StreamError.BIND,
+ stanza.getError(),
+ stanza.getErrorMsg())
return
jid = stanza.getTag('bind').getTagData('jid')
@@ -762,7 +753,9 @@ class Client(Observable):
self.set_state(StreamState.BIND_SUCCESSFUL)
else:
self._log.error('Session open failed')
- self.set_state(StreamState.SESSION_FAILED)
+ self._disconnect_with_error(StreamError.SESSION,
+ stanza.getError(),
+ stanza.getErrorMsg())
def _ping(self):
iq = Iq('get', to=self._jid.getBare())
diff --git a/nbxmpp/const.py b/nbxmpp/const.py
index d4479fb..4e64807 100644
--- a/nbxmpp/const.py
+++ b/nbxmpp/const.py
@@ -357,13 +357,11 @@ class StreamState(Enum):
PROCEED_WITH_AUTH = 'proceed with auth'
AUTH_SUCCESSFUL = 'auth successful'
AUTH_FAILED = 'auth failed'
- SESSION_FAILED = 'session failed'
WAIT_FOR_RESUMED = 'wait for resumed'
RESUME_FAILED = 'resume failed'
RESUME_SUCCESSFUL = 'resume successful'
PROCEED_WITH_BIND = 'proceed with bind'
BIND_SUCCESSFUL = 'bind successful'
- BIND_FAILED = 'bind failed'
WAIT_FOR_BIND = 'wait for bind'
WAIT_FOR_SESSION = 'wait for session'
ACTIVE = 'active'