diff options
author | Thom Nichols <tmnichols@gmail.com> | 2010-07-01 17:50:45 -0400 |
---|---|---|
committer | Thom Nichols <tmnichols@gmail.com> | 2010-07-01 17:50:45 -0400 |
commit | 62da57a6c26a16024dd481b364e5d1021bc3dd3b (patch) | |
tree | 9b0bb5e2907fb4a2e8cc48f844a9fb5431ad4c09 /sleekxmpp/xmlstream | |
parent | ba9633f8f7ef86c73dd02ad316e7963447a6239b (diff) | |
parent | f477ccf533a9b041e5f32b8b01e8381e05bcadf2 (diff) | |
download | slixmpp-62da57a6c26a16024dd481b364e5d1021bc3dd3b.tar.gz slixmpp-62da57a6c26a16024dd481b364e5d1021bc3dd3b.tar.bz2 slixmpp-62da57a6c26a16024dd481b364e5d1021bc3dd3b.tar.xz slixmpp-62da57a6c26a16024dd481b364e5d1021bc3dd3b.zip |
Merge branch 'master' of git://github.com/macdiesel/SleekXMPP into hacks
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r-- | sleekxmpp/xmlstream/stanzabase.py | 15 | ||||
-rw-r--r-- | sleekxmpp/xmlstream/xmlstream.py | 12 |
2 files changed, 16 insertions, 11 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 64020c8f..34513807 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -1,9 +1,9 @@ """ - SleekXMPP: The Sleek XMPP Library - Copyright (C) 2010 Nathanael C. Fritz - This file is part of SleekXMPP. + SleekXMPP: The Sleek XMPP Library + Copyright (C) 2010 Nathanael C. Fritz + This file is part of SleekXMPP. - See the file license.txt for copying permission. + See the file license.txt for copying permission. """ from xml.etree import cElementTree as ET import logging @@ -383,6 +383,7 @@ class StanzaBase(ElementBase): def exception(self, e): logging.error(traceback.format_tb(e)) - def send(self): - self.stream.sendRaw(self.__str__()) - + def send(self, priority=False): + if priority: self.stream.sendPriorityRaw(self.__str__()) + else: self.stream.sendRaw(self.__str__()) + diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index d5238f80..842dfee2 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -81,7 +81,7 @@ class XMLStream(object): self.stream_footer = "</stream>" self.eventqueue = queue.Queue() - self.sendqueue = queue.Queue() + self.sendqueue = queue.PriorityQueue() self.scheduler = scheduler.Scheduler(self.eventqueue) self.namespace_map = {} @@ -220,7 +220,7 @@ class XMLStream(object): while self.run: if not self.state.ensure('connected',wait=2): continue try: - self.sendRaw(self.stream_header) + self.sendPriorityRaw(self.stream_header) while self.run and self.__readXML(): pass except socket.timeout: logging.debug('socket rcv timeout') @@ -281,7 +281,7 @@ class XMLStream(object): data = None try: - data = self.sendqueue.get(True,5) + data = self.sendqueue.get(True,5)[1] logging.debug("SEND: %s" % data) self.socket.sendall(data.encode('utf-8')) except queue.Empty: @@ -302,7 +302,11 @@ class XMLStream(object): self.disconnect(reconnect=True) def sendRaw(self, data): - self.sendqueue.put(data) + self.sendqueue.put((1, data)) + return True + + def sendPriorityRaw(self, data): + self.sendqueue.put((0, data)) return True def disconnect(self, reconnect=False): |