Jaxl 类基回调



我想在我的项目中实现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 "donen";       
    }
    public function wait_for_register_form($event, $args) {
       // something
    }
}
示例register_user.php,其中将

FSM 状态扩展到基类之外的演示最初并不是为了适应您尝试实现的特定用例而编写的。我已经在 JAXLFsm 内部推送了一个补丁,现在允许您执行相同的操作。如果您对细节感兴趣,这里是提交日志。

现在尝试相同的方法,它应该可以工作。

最新更新