add now argument to send funtions in zeroconf connection. fixes #3045

This commit is contained in:
Yann Leboulanger 2007-03-20 07:13:25 +00:00
parent 61949ac74d
commit 3bf528d988
1 changed files with 9 additions and 4 deletions

View File

@ -310,8 +310,9 @@ class P2PConnection(IdleObject, PlugIn):
if not recv_handler(None) and _tmp == self.on_receive: if not recv_handler(None) and _tmp == self.on_receive:
self.on_receive = recv_handler self.on_receive = recv_handler
def send(self, packet, is_message = False): def send(self, packet, is_message = False, now = False):
'''Append stanza to the queue of messages to be send. '''Append stanza to the queue of messages to be send if now is
False, else send it instantly.
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:
@ -324,6 +325,10 @@ class P2PConnection(IdleObject, PlugIn):
elif not isinstance(r, str): elif not isinstance(r, str):
r = ustr(r).encode('utf-8') r = ustr(r).encode('utf-8')
if now:
self.sendqueue.insert(0, (r, is_message))
self._do_send()
else:
self.sendqueue.append((r, is_message)) self.sendqueue.append((r, is_message))
self._plug_idle() self._plug_idle()
@ -617,7 +622,7 @@ class ClientZeroconf:
return self.roster.getRoster() return self.roster.getRoster()
return {} return {}
def send(self, stanza, is_message = False): def send(self, stanza, is_message = False, now = False):
stanza.setFrom(self.roster.zeroconf.name) stanza.setFrom(self.roster.zeroconf.name)
to = stanza.getTo() to = stanza.getTo()