我想在我的项目中将 Jaxl 实现为类,但是所有 Jaxl 示例都是基于函数的。所有示例都使用闭包来运行回调。类中的方法无法像函数基编程那样访问。如何在类中调用 wait_for_register_form()?我的基类实现是这样的(注意粗体注释):
<?php
class XmppsController extends AppController {
public function test() {
require_once 'JAXL/jaxl.php';
global $client;
$client = new JAXL(array(
'jid' => 'localhost',
'log_level' => JAXL_INFO
));
$client->require_xep(array(
'0077' // InBand Registration
));
global $thisObj;
$thisObj = $this;
$client->add_cb('on_stream_features', function($stanza) {
global $client,$thisObj;
$client->xeps['0077']->get_form('localhost');
return "wait_for_register_form"; **//it calls wait_for_register_form() function, but I want call this function in class. how can I solve this problem?**
});
$client->start();
echo "done\n";
}
public function wait_for_register_form($event, $args) {
// something
}
}