Skip to content

Commit

Permalink
examples/attach: more robust check for a successful bind
Browse files Browse the repository at this point in the history
<bind> is not necessarily the first child element of <success> (it isn't
in the XML returned from Prosody 0.8).  Therefore, to robustly check if
a bind succeeded, we must check *all* the children of <success> for a
<bind> element.
  • Loading branch information
AGWA committed Aug 9, 2013
1 parent db26a80 commit 57c226d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion examples/attach/boshclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ def startSessionAndAuth(self, hold='1', wait='70'):
if elems[0].name == 'success':
retb, elems = self.sendBody(self.buildBody())

if elems[0].firstChildElement().name == 'bind':
has_bind = False
for child in elems[0].children:
if child.name == 'bind':
has_bind = True
break

if has_bind:
iq = domish.Element(('jabber:client', 'iq'))
iq['type'] = 'set'
iq.addUniqueId()
Expand Down

0 comments on commit 57c226d

Please sign in to comment.