Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from priyadi/master
Browse files Browse the repository at this point in the history
throw an exception when server doesn't give us list of mechanisms
  • Loading branch information
Piotr committed Oct 22, 2013
2 parents 597cada + 21abba8 commit ea46d9c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/XmppPrebind.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ public function connect($username, $password) {
$this->sid = $body->getAttribute('sid');
$this->debug($this->sid, 'sid');

$mechanisms = $body->firstChild->firstChild->getElementsByTagName('mechanism');
$child = $body->firstChild->firstChild;
if (is_object($child)) {
$mechanisms = $child->getElementsByTagName('mechanism');
} else {
throw new Exception('Invalid response');
}

foreach ($mechanisms as $value) {
$this->mechanisms[] = $value->nodeValue;
Expand Down Expand Up @@ -617,4 +622,4 @@ protected function getAndIncrementRid() {
*/
class XmppPrebindException extends Exception{}

class XmppPrebindConnectionException extends XmppPrebindException {}
class XmppPrebindConnectionException extends XmppPrebindException {}

0 comments on commit ea46d9c

Please sign in to comment.