* added support for SASL-ANONYMOUS

* changed BOSH session serialization


git-svn-id: svn://netflint.net/xmpphp@59 ef36c318-a008-4979-b6e8-6b496270793b
This commit is contained in:
fritzy 2008-09-22 00:12:13 +00:00
parent 756afc45a4
commit 454b0e0b7e
2 changed files with 16 additions and 10 deletions

View File

@ -169,18 +169,18 @@ class XMPPHP_BOSH extends XMPPHP_XMPP {
}
public function loadSession() {
if(isset($_SESSION['XMPPHP_BOSH']) and is_array($_SESSION['XMPPHP_BOSH'])) {
foreach($_SESSION['XMPPHP_BOSH'] as $key => $value) {
#print "Loading $key as $value<br/>";
$this->$key = $value;
}
}
if(isset($_SESSION['XMPPHP_BOSH_RID'])) $this->rid = $_SESSION['XMPPHP_BOSH_RID'];
if(isset($_SESSION['XMPPHP_BOSH_SID'])) $this->sid = $_SESSION['XMPPHP_BOSH_SID'];
if(isset($_SESSION['XMPPHP_BOSH_authed'])) $this->authed = $_SESSION['XMPPHP_BOSH_authed'];
if(isset($_SESSION['XMPPHP_BOSH_jid'])) $this->jid = $_SESSION['XMPPHP_BOSH_jid'];
if(isset($_SESSION['XMPPHP_BOSH_fulljid'])) $this->fulljid = $_SESSION['XMPPHP_BOSH_fulljid'];
}
public function saveSession() {
$_SESSION['XMPPHP_BOSH'] = Array();
$_SESSION['XMPPHP_BOSH']['rid'] = (string) $this->rid;
$_SESSION['XMPPHP_BOSH']['sid'] = (string) $this->sid;
$_SESSION['XMPPHP_BOSH']['authed'] = (boolean) $this->authed;
$_SESSION['XMPPHP_BOSH_RID'] = (string) $this->rid;
$_SESSION['XMPPHP_BOSH_SID'] = (string) $this->sid;
$_SESSION['XMPPHP_BOSH_authed'] = (boolean) $this->authed;
$_SESSION['XMPPHP_BOSH_jid'] = (string) $this->jid;
$_SESSION['XMPPHP_BOSH_fulljid'] = (string) $this->fulljid;
}
}

View File

@ -246,7 +246,11 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream {
$this->send("<iq xmlns=\"jabber:client\" type=\"set\" id=\"$id\"><bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"><resource>{$this->resource}</resource></bind></iq>");
} else {
$this->log->log("Attempting Auth...");
if ($this->password) {
$this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->user . "\x00" . $this->password) . "</auth>");
} else {
$this->send("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/>");
}
}
}
@ -282,6 +286,8 @@ class XMPPHP_XMPP extends XMPPHP_XMLStream {
if($xml->attrs['type'] == 'result') {
$this->log->log("Bound to " . $xml->sub('bind')->sub('jid')->data);
$this->fulljid = $xml->sub('bind')->sub('jid')->data;
$jidarray = explode('/',$this->fulljid);
$this->jid = $jidarray[0];
}
$id = $this->getId();
$this->addIdHandler($id, 'session_start_handler');