Skip to content

Commit 6125ead

Browse files
committed
Better ID uniqueness generation
1 parent 35c77e4 commit 6125ead

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

xmpp/dispatcher.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## transports.py
1+
## dispatcher.py
22
##
33
## Copyright (C) 2003-2005 Alexey "Snake" Nezhdanov
44
##
@@ -21,12 +21,13 @@
2121
Dispatcher.SendAndWaitForResponce method will wait for reply stanza before giving up.
2222
"""
2323

24-
import simplexml,time,sys
24+
import simplexml,time,sys,random
2525
from protocol import *
2626
from client import PlugIn
2727

2828
DefaultTimeout=25
2929
ID=0
30+
SALT=random.randint(1,100000)
3031

3132
class Dispatcher(PlugIn):
3233
""" Ancestor of PlugIn class. Handles XMPP stream, i.e. aware of stream headers.
@@ -350,7 +351,7 @@ def send(self,stanza):
350351
elif not stanza.getID():
351352
global ID
352353
ID+=1
353-
_ID=`ID`
354+
_ID="%s_#%s#-%s" % (self._owner.User, SALT, `ID`)
354355
stanza.setID(_ID)
355356
else: _ID=stanza.getID()
356357
if self._owner._registered_name and not stanza.getAttr('from'): stanza.setAttr('from',self._owner._registered_name)

0 commit comments

Comments
 (0)