From f5d04664627b28f9439d9ed5214a0060a77a2bf2 Mon Sep 17 00:00:00 2001 From: Brian Beggs Date: Fri, 18 Jun 2010 09:51:29 -0400 Subject: working on digest-md5 authentication --- sleekxmpp/xmlstream/xmlstream.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sleekxmpp/xmlstream') diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 6dbe7b30..a8bcac00 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -82,7 +82,7 @@ class XMLStream(object): self.stream_footer = "" self.eventqueue = queue.Queue() - self.sendqueue = queue.Queue() + self.sendqueue = queue.PriorityQueue() self.scheduler = scheduler.Scheduler(self.eventqueue) self.namespace_map = {} @@ -219,7 +219,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') @@ -277,7 +277,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: @@ -298,7 +298,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): @@ -306,7 +310,7 @@ class XMLStream(object): logging.warning("Already disconnected.") return logging.debug("Disconnecting...") - self.sendRaw(self.stream_footer) + self.sendPriorityRaw(self.stream_footer) time.sleep(5) #send end of stream #wait for end of stream back -- cgit v1.2.3