resuming before binding
This commit is contained in:
parent
39a960f3e7
commit
d73e277f40
|
@ -712,7 +712,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
self.streamError = ''
|
||||
self.secret_hmac = str(random.random())[2:]
|
||||
|
||||
self.sm = Smacks(self)
|
||||
self.sm = Smacks(self) # Stream Management
|
||||
|
||||
gajim.ged.register_event_handler('privacy-list-received', ged.CORE,
|
||||
self._nec_privacy_list_received)
|
||||
|
@ -805,8 +805,9 @@ class Connection(CommonConnection, ConnectionHandlers):
|
|||
self.old_show = gajim.SHOW_LIST[self.connected]
|
||||
self.connected = 0
|
||||
if not self.on_purpose:
|
||||
gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
|
||||
show='offline'))
|
||||
if not (self.sm and self.sm.resumption):
|
||||
gajim.nec.push_incoming_event(OurShowEvent(None, conn=self,
|
||||
show='offline'))
|
||||
self.disconnect()
|
||||
if gajim.config.get_per('accounts', self.name, 'autoreconnect'):
|
||||
self.connected = -1
|
||||
|
|
|
@ -574,6 +574,7 @@ class NonBlockingBind(PlugIn):
|
|||
PlugIn.__init__(self)
|
||||
self.bound = None
|
||||
self.supports_sm = False
|
||||
self.resuming = False
|
||||
|
||||
def plugin(self, owner):
|
||||
''' Start resource binding, if allowed at this time. Used internally. '''
|
||||
|
@ -597,6 +598,8 @@ class NonBlockingBind(PlugIn):
|
|||
|
||||
if feats.getTag('sm', namespace=NS_STREAM_MGMT):
|
||||
self.supports_sm = True # server supports stream management
|
||||
if self.resuming:
|
||||
self._owner._caller.sm.resume_request()
|
||||
|
||||
if not feats.getTag('bind', namespace=NS_BIND):
|
||||
log.info('Server does not requested binding.')
|
||||
|
@ -621,6 +624,8 @@ class NonBlockingBind(PlugIn):
|
|||
"""
|
||||
Perform binding. Use provided resource name or random (if not provided).
|
||||
"""
|
||||
if self.resuming: # We don't bind if we resume the stream
|
||||
return
|
||||
self.on_bound = on_bound
|
||||
self._resource = resource
|
||||
if self._resource:
|
||||
|
@ -646,13 +651,8 @@ class NonBlockingBind(PlugIn):
|
|||
sm = self._owner._caller.sm
|
||||
if self.supports_sm:
|
||||
# starts negociation
|
||||
if sm._owner and sm.resumption:
|
||||
sm.set_owner(self._owner)
|
||||
sm.resume_request()
|
||||
else:
|
||||
sm.set_owner(self._owner)
|
||||
sm.negociate()
|
||||
|
||||
sm.set_owner(self._owner)
|
||||
sm.negociate()
|
||||
self._owner.Dispatcher.sm = sm
|
||||
|
||||
if hasattr(self, 'session') and self.session == -1:
|
||||
|
@ -670,7 +670,7 @@ class NonBlockingBind(PlugIn):
|
|||
else:
|
||||
log.info('Binding failed: timeout expired.')
|
||||
self.on_bound(None)
|
||||
|
||||
|
||||
def _on_session(self, resp):
|
||||
self._owner.onreceive(None)
|
||||
if isResultNode(resp):
|
||||
|
|
|
@ -521,8 +521,20 @@ class NonBlockingClient:
|
|||
self.connected = None # FIXME: is this intended? We use ''elsewhere
|
||||
self._on_sasl_auth(None)
|
||||
elif self.SASL.startsasl == 'success':
|
||||
auth_nb.NonBlockingBind.get_instance().PlugIn(self)
|
||||
nb_bind = auth_nb.NonBlockingBind.get_instance()
|
||||
sm = self._caller.sm
|
||||
if sm._owner and sm.resumption:
|
||||
nb_bind.resuming = True
|
||||
sm.set_owner(self)
|
||||
self.Dispatcher.sm = sm
|
||||
nb_bind.PlugIn(self)
|
||||
return
|
||||
|
||||
|
||||
nb_bind.PlugIn(self)
|
||||
self.onreceive(self._on_auth_bind)
|
||||
|
||||
|
||||
return True
|
||||
|
||||
def _on_auth_bind(self, data):
|
||||
|
|
|
@ -73,7 +73,7 @@ class Smacks():
|
|||
return
|
||||
resume = Acks()
|
||||
resume.buildResume(self.in_h, self.session_id)
|
||||
self._owner.Connection.send(resume, True)
|
||||
self._owner.Connection.send(resume, False)
|
||||
|
||||
def send_ack(self, disp, stanza):
|
||||
ack = Acks()
|
||||
|
|
Loading…
Reference in New Issue