summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slixmpp/basexmpp.py2
-rw-r--r--slixmpp/plugins/xep_0333/markers.py5
-rw-r--r--slixmpp/stanza/message.py8
-rw-r--r--slixmpp/xmlstream/xmlstream.py23
4 files changed, 23 insertions, 15 deletions
diff --git a/slixmpp/basexmpp.py b/slixmpp/basexmpp.py
index cd228312..c54ec63a 100644
--- a/slixmpp/basexmpp.py
+++ b/slixmpp/basexmpp.py
@@ -140,7 +140,7 @@ class BaseXMPP(XMLStream):
self.use_presence_ids = True
#: XEP-0359 <origin-id/> tag that gets added to <message/> stanzas.
- self.use_origin_id = True
+ self.use_origin_id = False
#: The API registry is a way to process callbacks based on
#: JID+node combinations. Each callback in the registry is
diff --git a/slixmpp/plugins/xep_0333/markers.py b/slixmpp/plugins/xep_0333/markers.py
index ca7a27da..86ddf612 100644
--- a/slixmpp/plugins/xep_0333/markers.py
+++ b/slixmpp/plugins/xep_0333/markers.py
@@ -1,4 +1,3 @@
-
# slixmpp: The Slick XMPP Library
# Copyright (C) 2016 Emmanuel Gil Peyrot
# This file is part of slixmpp.
@@ -68,11 +67,11 @@ class XEP_0333(BasePlugin):
:param JID mto: recipient of the marker
:param str id: Identifier of the marked message
:param str marker: Marker to send (one of
- displayed, retrieved, or acknowledged)
+ displayed, received, or acknowledged)
:param str thread: Message thread
:param str mfrom: Use a specific JID to send the message
"""
- if marker not in ('displayed', 'retrieved', 'acknowledged'):
+ if marker not in ('displayed', 'received', 'acknowledged'):
raise ValueError('Invalid marker: %s' % marker)
msg = self.xmpp.make_message(mto=mto, mfrom=mfrom)
if thread:
diff --git a/slixmpp/stanza/message.py b/slixmpp/stanza/message.py
index 50d32ff0..eda11df6 100644
--- a/slixmpp/stanza/message.py
+++ b/slixmpp/stanza/message.py
@@ -64,9 +64,9 @@ class Message(RootStanza):
if self.stream:
use_ids = getattr(self.stream, 'use_message_ids', None)
if use_ids:
- self['id'] = self.stream.new_id()
+ self.set_id(self.stream.new_id())
else:
- del self['origin_id']
+ self.del_origin_id()
def get_type(self):
"""
@@ -96,8 +96,8 @@ class Message(RootStanza):
self.xml.attrib['id'] = value
if self.stream:
- use_orig_ids = getattr(self.stream, 'use_origin_id', None)
- if not use_orig_ids:
+ if not getattr(self.stream, 'use_origin_id', False):
+ self.del_origin_id()
return None
sub = self.xml.find(ORIGIN_NAME)
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index 18143f87..06d48f5c 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -493,16 +493,11 @@ class XMLStream(asyncio.BaseProtocol):
except Socket.gaierror as e:
self.event('connection_failed',
'No DNS record available for %s' % self.default_domain)
+ self.reschedule_connection_attempt()
except OSError as e:
log.debug('Connection failed: %s', e)
self.event("connection_failed", e)
- if self._current_connection_attempt is None:
- return
- self._connect_loop_wait = self._connect_loop_wait * 2 + 1
- self._current_connection_attempt = asyncio.ensure_future(
- self._connect_routine(),
- loop=self.loop,
- )
+ self.reschedule_connection_attempt()
def process(self, *, forever: bool = True, timeout: Optional[int] = None) -> None:
"""Process all the available XMPP events (receiving or sending data on the
@@ -638,6 +633,20 @@ class XMLStream(asyncio.BaseProtocol):
self._set_disconnected_future()
self.event("disconnected", self.disconnect_reason or exception)
+ def reschedule_connection_attempt(self) -> None:
+ """
+ Increase the exponential back-off and initate another background
+ _connect_routine call to connect to the server.
+ """
+ # abort if there is no ongoing connection attempt
+ if self._current_connection_attempt is None:
+ return
+ self._connect_loop_wait = min(300, self._connect_loop_wait * 2 + 1)
+ self._current_connection_attempt = asyncio.ensure_future(
+ self._connect_routine(),
+ loop=self.loop,
+ )
+
def cancel_connection_attempt(self) -> None:
"""
Immediately cancel the current create_connection() Future.