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,15 +484,17 @@ class NonBlockingBind(PlugIn):
def _on_bound(self, resp): def _on_bound(self, resp):
if isResultNode(resp): if isResultNode(resp):
self.bound.append(resp.getTag('bind').getTagData('jid')) if resp.getTag('bind') and resp.getTag('bind').getTagData('jid'):
log.info('Successfully bound %s.' % self.bound[-1]) self.bound.append(resp.getTag('bind').getTagData('jid'))
jid = JID(resp.getTag('bind').getTagData('jid')) log.info('Successfully bound %s.' % self.bound[-1])
self._owner.User = jid.getNode() jid = JID(resp.getTag('bind').getTagData('jid'))
self._owner.Resource = jid.getResource() self._owner.User = jid.getNode()
self._owner.SendAndWaitForResponse(Protocol('iq', typ='set', self._owner.Resource = jid.getResource()
payload=[Node('session', attrs={'xmlns':NS_SESSION})]), self._owner.SendAndWaitForResponse(Protocol('iq', typ='set',
func=self._on_session) payload=[Node('session', attrs={'xmlns':NS_SESSION})]),
elif resp: func=self._on_session)
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: