Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

checking in a working example of http_pre_bind.php with related tweak…

…s in stack files
  • Loading branch information...
commit 34a6c5aa4aaec7d6196256b1ca7e61400404b624 1 parent 9fa38c1
@abhinavsingh abhinavsingh authored
View
8 examples/echo_bot.php
@@ -36,8 +36,12 @@
*
*/
+// Run as:
+// php examples/echo_bot.php root@localhost password
+// php examples/echo_bot.php root@localhost password DIGEST-MD5
+// php examples/echo_bot.php localhost "" ANONYMOUS
if($argc < 3) {
- echo "Usage: $argv[0] jid pass\n";
+ echo "Usage: $argv[0] jid pass auth_type\n";
exit;
}
@@ -102,8 +106,8 @@
$client->add_cb('on_auth_failure', function($reason) {
global $client;
- $client->send_end_stream();
_info("got on_auth_failure cb with reason $reason");
+ $client->send_end_stream();
});
$client->add_cb('on_chat_message', function($stanza) {
View
25 examples/http_pre_bind.php
@@ -49,13 +49,12 @@
//
// initialize JAXL object with initial config
//
-require_once 'jaxl.php';
+require_once '../jaxl.php';
-$to = $attrs['to'];
-$rid = $attrs['rid'];
-$wait = $attrs['wait'];
-$hold = $attrs['hold'];
-echo $to." ".$rid." ".$wait." ".$hold; exit;
+$to = (string)$attrs['to'];
+$rid = (int)$attrs['rid'];
+$wait = (int)$attrs['wait'];
+$hold = (int)$attrs['hold'];
list($host, $port) = JAXLUtil::get_dns_srv($to);
$client = new JAXL(array(
@@ -66,17 +65,23 @@
'bosh_rid' => $rid,
'bosh_wait' => $wait,
'bosh_hold' => $hold,
- 'auth_type' => 'ANONYMOUS'
+ 'auth_type' => 'ANONYMOUS',
+ 'log_level' => JAXL_INFO
));
$client->add_cb('on_auth_success', function() {
global $client;
- _info($client->full_jid->to_string());
- _info($client->xeps['0206']->sid);
- _info($client->xeps['0206']->rid);
+ _info("got on_auth_success cb, jid ".$client->full_jid->to_string());
+ echo '<body xmlns="'.NS_HTTP_BIND.'" sid="'.$client->xeps['0206']->sid.'" rid="'.$client->xeps['0206']->rid.'" jid="'.$client->full_jid->to_string().'"/>';
exit;
});
+$client->add_cb('on_auth_failure', function($reason) {
+ global $client;
+ _info("got on_auth_failure cb with reason $reason");
+ $client->send_end_stream();
+});
+
//
// finally start configured xmpp stream
//
View
2  xep/xep_0206.php
@@ -106,7 +106,7 @@ public function send($body) {
$body = $this->wrap($body);
}
}
- _debug("send to ".$this->jaxl->cfg['bosh_url']." body ".$body);
+ _debug("posting to ".$this->jaxl->cfg['bosh_url']." body ".$body);
$this->chs[$this->rid] = curl_init($this->jaxl->cfg['bosh_url']);
curl_setopt($this->chs[$this->rid], CURLOPT_RETURNTRANSFER, true);
View
6 xmpp/xmpp_stream.php
@@ -128,7 +128,11 @@ public function send_raw($data) {
//
public function get_start_stream($jid) {
- return '<stream:stream xmlns:stream="'.NS_XMPP.'" version="1.0" from="'.$jid->bare.'" to="'.$jid->domain.'" xmlns="'.NS_JABBER_CLIENT.'" xml:lang="en" xmlns:xml="'.NS_XML.'">';
+ $xml = '<stream:stream xmlns:stream="'.NS_XMPP.'" version="1.0" ';
+ if(isset($jid->bare)) $xml .= 'from="'.$jid->bare.'" ';
+ if(isset($jid->domain)) $xml .= 'to="'.$jid->domain.'" ';
+ $xml .= 'xmlns="'.NS_JABBER_CLIENT.'" xml:lang="en" xmlns:xml="'.NS_XML.'">';
+ return $xml;
}
public function get_end_stream() {
Please sign in to comment.
Something went wrong with that request. Please try again.