jaxl php,php – jaxl返回它调用的函数

我有使用jaxl库的xmpp事务库:

class xmpp{

public function register_user($username, $password){

require_once 'JAXL/jaxl.php';

$this->client = new JAXL(array(

'jid' => 'localhost',

'log_level' => JAXL_ERROR

));

$this->username = $username;

$this->password = $password;

$this->client->require_xep(array(

'0077' // InBand Registration

));

$thisClassObject =& $this;

$this->client->add_cb('on_stream_features', function($stanza) use(&$thisClassObject) {

$thisClassObject->client->xeps['0077']->get_form('localhost');

return array($thisClassObject, 'wait_for_register_form');

});

$this->client->start();

return;

}

public function wait_for_register_response($event, $args) {

if($event == 'end_stream') {

return;

}

else if($event == 'stanza_cb') {

$stanza = $args[0];

if($stanza->name == 'iq') {

if($stanza->attrs['type'] == 'result') {

echo "registration successful".PHP_EOL."shutting down...".PHP_EOL;

$this->client->end_stream();

return 'logged_out';

}

else if($stanza->attrs['type'] == 'error') {

$error = $stanza->exists('error');

echo "registration failed with error code: ".$error->attrs['code']." and type: ".$error->attrs['type'].PHP_EOL;

echo "error text: ".$error->exists('text')->text.PHP_EOL;

echo "shutting down...".PHP_EOL;

$this->client->end_stream();

return "logged_out";

}

}

}

}

public function wait_for_register_form($event, $args) {

$stanza = $args[0];

$query = $stanza->exists('query', NS_INBAND_REGISTER);

if($query) {

$form = array();

$instructions = $query->exists('instructions');

if($instructions) {

echo $instructions->text.PHP_EOL;

}

$this->client->xeps['0077']->set_form($stanza->attrs['from'], array('username' => $this->username, 'password' => $this->password));

return array($this, "wait_for_register_response");

}

else {

$this->client->end_stream();

return "logged_out";

}

}

}

这些代码与register_user.php相同,但在类中实现;

我以这种方式在我的代码中使用这个类:

$xmppObj = new xmpp();

$xmppObj('user','password');

/*

some more code after this

/*

当它执行时,创建用户成功,但它打印一条消息(‘注册成功…’)并退出应用程序,并且它不会在类函数之后执行“之后的某些代码”,换句话说它不跟随代码…

我能做些什么来解决这个问题,一个人可以帮助我熟悉JAXL库.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值