Question

I want to implement Jaxl in my project as class, But all Jaxl examples are function based.All examples use closure to run callbacks.Methods in class are not accessible like function base programming.How can I call wait_for_register_form() in the class? My base class implementation is like this(Notice bold comment):

    <?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
    }
}
Was it helpful?

Solution

Example register_user.php which demos extending FSM states outside of base classes wasn't initially written to accomodate the particular use case you are trying to achieve. I have pushed a patch inside of JAXLFsm which will now allow you to do the same. Here is the commit log if you are interested in the particulars.

Try the same now and it should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top