Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jaxl class base callback

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
    }
}
like image 444
realman Avatar asked Dec 06 '25 01:12

realman


1 Answers

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.

like image 126
Abhinav Singh Avatar answered Dec 08 '25 14:12

Abhinav Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!