3
我想在我的項目中實現Jaxl作爲類,但所有Jaxl示例都是基於函數的。所有示例都使用closure來運行回調。類中的方法不能像函數基編程那樣訪問。如何調用wait_for_register_form () 在課堂裏? 我的基類的實現是這樣的(注意:黑體評論):Jaxl class base callback
<?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
}
}