summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-04-08 21:15:53 -0400
committerLance Stout <lancestout@gmail.com>2012-04-08 21:15:53 -0400
commit15ef27314189baeee64fbe41ab87f1eebef6e85c (patch)
tree7301f7518332bb0a2c5295b9f42a3e9aa3dd2fcf /sleekxmpp/xmlstream
parenteed6da538a33711f19adc70b00071af43005062a (diff)
downloadslixmpp-15ef27314189baeee64fbe41ab87f1eebef6e85c.tar.gz
slixmpp-15ef27314189baeee64fbe41ab87f1eebef6e85c.tar.bz2
slixmpp-15ef27314189baeee64fbe41ab87f1eebef6e85c.tar.xz
slixmpp-15ef27314189baeee64fbe41ab87f1eebef6e85c.zip
Add a prefix to stanza ID values to ensure that they are unique per client.
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 145383c1..808464f0 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -25,6 +25,7 @@ import threading
import time
import random
import weakref
+import uuid
try:
import queue
except ImportError:
@@ -285,6 +286,9 @@ class XMLStream(object):
self._id = 0
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 stream will be restarted in the event of an error.
self.auto_reconnect = True
@@ -367,7 +371,7 @@ class XMLStream(object):
def get_id(self):
"""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,
use_tls=True, reattempt=True):