flush xmpppy's send queue before disconnecting
This commit is contained in:
parent
304da5e252
commit
b0aeefcbb5
|
@ -393,6 +393,11 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
|
|
||||||
def start_disconnect(self, to_send, on_disconnect):
|
def start_disconnect(self, to_send, on_disconnect):
|
||||||
self.on_disconnect = on_disconnect
|
self.on_disconnect = on_disconnect
|
||||||
|
|
||||||
|
# flush the sendqueue
|
||||||
|
while self.sendqueue:
|
||||||
|
self._do_send()
|
||||||
|
|
||||||
self.sendqueue = []
|
self.sendqueue = []
|
||||||
self.send(to_send)
|
self.send(to_send)
|
||||||
self.send('</stream:stream>')
|
self.send('</stream:stream>')
|
||||||
|
@ -596,6 +601,7 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
'''Append raw_data to the queue of messages to be send.
|
'''Append raw_data to the queue of messages to be send.
|
||||||
If supplied data is unicode string, encode it to utf-8.
|
If supplied data is unicode string, encode it to utf-8.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if self.state <= 0:
|
if self.state <= 0:
|
||||||
return
|
return
|
||||||
r = raw_data
|
r = raw_data
|
||||||
|
@ -608,6 +614,7 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
||||||
self._do_send()
|
self._do_send()
|
||||||
else:
|
else:
|
||||||
self.sendqueue.append(r)
|
self.sendqueue.append(r)
|
||||||
|
|
||||||
self._plug_idle()
|
self._plug_idle()
|
||||||
|
|
||||||
def _on_send(self):
|
def _on_send(self):
|
||||||
|
|
Loading…
Reference in New Issue