2012-10-03 55 views
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 
    } 
} 

回答

3

register_user.php其扩展基类之外FSM状态演示最初没有写来容纳你正在努力实现的具体使用情况。我已经在JAXLFsm之内推出了一个补丁,现在可以让你做同样的事情。如果你对这些细节感兴趣,这里是commit log

现在试试吧,它应该工作。