summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-11-18 00:44:51 -0500
committerLance Stout <lancestout@gmail.com>2010-11-18 00:44:51 -0500
commit58b95e4ae45432ae97bd643c591f4f078f29f300 (patch)
tree0bf29e982c6f7a7d486d00f01188e021ab193aa1 /sleekxmpp/xmlstream
parentdebf90935981622c7b23009b7edeb311fd57ee5c (diff)
parent60d3afe6b6814bb5d30c4d4d355451d3c15364ca (diff)
downloadslixmpp-58b95e4ae45432ae97bd643c591f4f078f29f300.tar.gz
slixmpp-58b95e4ae45432ae97bd643c591f4f078f29f300.tar.bz2
slixmpp-58b95e4ae45432ae97bd643c591f4f078f29f300.tar.xz
slixmpp-58b95e4ae45432ae97bd643c591f4f078f29f300.zip
Merge branch 'develop' of github.com:fritzy/SleekXMPP into roster
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r--sleekxmpp/xmlstream/handler/waiter.py7
-rw-r--r--sleekxmpp/xmlstream/jid.py3
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py15
3 files changed, 19 insertions, 6 deletions
diff --git a/sleekxmpp/xmlstream/handler/waiter.py b/sleekxmpp/xmlstream/handler/waiter.py
index a4bc3545..341c01fe 100644
--- a/sleekxmpp/xmlstream/handler/waiter.py
+++ b/sleekxmpp/xmlstream/handler/waiter.py
@@ -12,7 +12,7 @@ try:
except ImportError:
import Queue as queue
-from sleekxmpp.xmlstream import StanzaBase, RESPONSE_TIMEOUT
+from sleekxmpp.xmlstream import StanzaBase
from sleekxmpp.xmlstream.handler.base import BaseHandler
@@ -69,7 +69,7 @@ class Waiter(BaseHandler):
"""
pass
- def wait(self, timeout=RESPONSE_TIMEOUT):
+ def wait(self, timeout=None):
"""
Block an event handler while waiting for a stanza to arrive.
@@ -84,6 +84,9 @@ class Waiter(BaseHandler):
arrive. Defaults to the global default timeout
value sleekxmpp.xmlstream.RESPONSE_TIMEOUT.
"""
+ if timeout is None:
+ timeout = self.stream.response_timeout
+
try:
stanza = self._payload.get(True, timeout)
except queue.Empty:
diff --git a/sleekxmpp/xmlstream/jid.py b/sleekxmpp/xmlstream/jid.py
index 33d845a0..d8f45b92 100644
--- a/sleekxmpp/xmlstream/jid.py
+++ b/sleekxmpp/xmlstream/jid.py
@@ -121,3 +121,6 @@ class JID(object):
def __str__(self):
"""Use the full JID as the string value."""
return self.full
+
+ def __repr__(self):
+ return str(self)
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 30b76ce7..9ae31a20 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -25,6 +25,8 @@ except ImportError:
from sleekxmpp.thirdparty.statemachine import StateMachine
from sleekxmpp.xmlstream import Scheduler, tostring
from sleekxmpp.xmlstream.stanzabase import StanzaBase, ET
+from sleekxmpp.xmlstream.handler import Waiter, XMLCallback
+from sleekxmpp.xmlstream.matcher import MatchXMLMask
# In Python 2.x, file socket objects are broken. A patched socket
# wrapper is provided for this case in filesocket.py.
@@ -162,6 +164,8 @@ class XMLStream(object):
self.ssl_support = SSL_SUPPORT
self.ssl_version = ssl.PROTOCOL_TLSv1
+ self.response_timeout = RESPONSE_TIMEOUT
+
self.state = StateMachine(('disconnected', 'connected'))
self.state._set_state('disconnected')
@@ -458,8 +462,6 @@ class XMLStream(object):
"""
# To prevent circular dependencies, we must load the matcher
# and handler classes here.
- from sleekxmpp.xmlstream.matcher import MatchXMLMask
- from sleekxmpp.xmlstream.handler import XMLCallback
if name is None:
name = 'add_handler_%s' % self.getNewId()
@@ -606,7 +608,7 @@ class XMLStream(object):
"""
return xml
- def send(self, data, mask=None, timeout=RESPONSE_TIMEOUT):
+ def send(self, data, mask=None, timeout=None):
"""
A wrapper for send_raw for sending stanza objects.
@@ -621,6 +623,9 @@ class XMLStream(object):
timeout -- Time in seconds to wait for a response before
continuing. Defaults to RESPONSE_TIMEOUT.
"""
+ if timeout is None:
+ timeout = self.response_timeout
+
if hasattr(mask, 'xml'):
mask = mask.xml
data = str(data)
@@ -643,7 +648,7 @@ class XMLStream(object):
self.send_queue.put(data)
return True
- def send_xml(self, data, mask=None, timeout=RESPONSE_TIMEOUT):
+ def send_xml(self, data, mask=None, timeout=None):
"""
Send an XML object on the stream, and optionally wait
for a response.
@@ -657,6 +662,8 @@ class XMLStream(object):
timeout -- Time in seconds to wait for a response before
continuing. Defaults to RESPONSE_TIMEOUT.
"""
+ if timeout is None:
+ timeout = self.response_timeout
return self.send(tostring(data), mask, timeout)
def process(self, threaded=True):