Add a prefix to stanza ID values to ensure that they are unique per client.
This commit is contained in:
parent
eed6da538a
commit
15ef273141
@ -330,6 +330,9 @@ class SleekTest(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
raise ValueError("Unknown XMPP connection mode.")
|
raise ValueError("Unknown XMPP connection mode.")
|
||||||
|
|
||||||
|
# Remove unique ID prefix to make it easier to test
|
||||||
|
self.xmpp._id_prefix = ''
|
||||||
|
|
||||||
# We will use this to wait for the session_start event
|
# We will use this to wait for the session_start event
|
||||||
# for live connections.
|
# for live connections.
|
||||||
skip_queue = queue.Queue()
|
skip_queue = queue.Queue()
|
||||||
|
@ -25,6 +25,7 @@ import threading
|
|||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
import weakref
|
import weakref
|
||||||
|
import uuid
|
||||||
try:
|
try:
|
||||||
import queue
|
import queue
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -285,6 +286,9 @@ class XMLStream(object):
|
|||||||
self._id = 0
|
self._id = 0
|
||||||
self._id_lock = threading.Lock()
|
self._id_lock = threading.Lock()
|
||||||
|
|
||||||
|
#: We use an ID prefix to ensure that all ID values are unique.
|
||||||
|
self._id_prefix = '%s-' % uuid.uuid4()
|
||||||
|
|
||||||
#: The :attr:`auto_reconnnect` setting controls whether or not
|
#: The :attr:`auto_reconnnect` setting controls whether or not
|
||||||
#: the stream will be restarted in the event of an error.
|
#: the stream will be restarted in the event of an error.
|
||||||
self.auto_reconnect = True
|
self.auto_reconnect = True
|
||||||
@ -367,7 +371,7 @@ class XMLStream(object):
|
|||||||
|
|
||||||
def get_id(self):
|
def get_id(self):
|
||||||
"""Return the current unique stream ID in hexadecimal form."""
|
"""Return the current unique stream ID in hexadecimal form."""
|
||||||
return "%X" % self._id
|
return "%s%X" % (self._id_prefix, self._id)
|
||||||
|
|
||||||
def connect(self, host='', port=0, use_ssl=False,
|
def connect(self, host='', port=0, use_ssl=False,
|
||||||
use_tls=True, reattempt=True):
|
use_tls=True, reattempt=True):
|
||||||
|
Loading…
Reference in New Issue
Block a user