Commit 9c8b63af authored by zimio's avatar zimio

Checks for stanzas handled by server

parent 5b1edd03
......@@ -533,6 +533,13 @@ class XMPPDispatcher(PlugIn):
ID = stanza.getID()
if self._owner._registered_name and not stanza.getAttr('from'):
stanza.setAttr('from', self._owner._registered_name)
if self.supports_sm:
self.sm.uqueue.append(stanza)
self.sm.out_h = self.sm.out_h + 1
if len(self.sm.uqueue) > self.sm.max_queue:
self.sm.request_ack()
self._owner.Connection.send(stanza, now)
return ID
......
from protocol import Acks
from protocol import NS_STREAM_MGMT
import logging
log = logging.getLogger('gajim.c.x.smacks')
class Smacks():
'''
......@@ -16,13 +18,16 @@ class Smacks():
self.out_h = 0 # Outgoing stanzas handled
self.in_h = 0 # Incoming stanzas handled
self.uqueue = [] # Unhandled stanzas queue
#Register handlers
# Max number of stanzas in queue before making a request
self.max_queue = 5
# Register handlers
owner.Dispatcher.RegisterNamespace(NS_STREAM_MGMT)
owner.Dispatcher.RegisterHandler('enabled', self._neg_response
,xmlns=NS_STREAM_MGMT)
owner.Dispatcher.RegisterHandler('r', self.send_ack
,xmlns=NS_STREAM_MGMT)
owner.Dispatcher.RegisterHandler('a', self.check_ack
,xmlns=NS_STREAM_MGMT)
def negociate(self):
......@@ -42,3 +47,18 @@ class Smacks():
r = Acks()
r.buildRequest()
self._owner.Connection.send(r, False)
def check_ack(self, disp, stanza):
h = int(stanza.getAttr('h'))
diff = self.out_h - h
if len(self.uqueue) < diff or diff < 0:
log.error('Server and client number of stanzas handled mismatch ')
return
while (len(self.uqueue) > diff):
self.uqueue.pop(0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment