prevent Traceback when server replies badly to resource binding request. Fixes #4880

This commit is contained in:
Yann Leboulanger 2009-03-16 09:54:57 +00:00
parent a9f233d2cd
commit 9b5c8db2ce
1 changed files with 11 additions and 9 deletions

View File

@ -484,6 +484,7 @@ class NonBlockingBind(PlugIn):
def _on_bound(self, resp): def _on_bound(self, resp):
if isResultNode(resp): if isResultNode(resp):
if resp.getTag('bind') and resp.getTag('bind').getTagData('jid'):
self.bound.append(resp.getTag('bind').getTagData('jid')) self.bound.append(resp.getTag('bind').getTagData('jid'))
log.info('Successfully bound %s.' % self.bound[-1]) log.info('Successfully bound %s.' % self.bound[-1])
jid = JID(resp.getTag('bind').getTagData('jid')) jid = JID(resp.getTag('bind').getTagData('jid'))
@ -492,7 +493,8 @@ class NonBlockingBind(PlugIn):
self._owner.SendAndWaitForResponse(Protocol('iq', typ='set', self._owner.SendAndWaitForResponse(Protocol('iq', typ='set',
payload=[Node('session', attrs={'xmlns':NS_SESSION})]), payload=[Node('session', attrs={'xmlns':NS_SESSION})]),
func=self._on_session) func=self._on_session)
elif resp: return
if resp:
log.error('Binding failed: %s.' % resp.getTag('error')) log.error('Binding failed: %s.' % resp.getTag('error'))
self.on_bound(None) self.on_bound(None)
else: else: