Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jaxl after send message callback

Tags:

php

xmpp

xmpphp

I want execute some code after a message has already sent in jaxl. which callback is appropriate for this situation?

    public function test() {

        require_once 'JAXL/jaxl.php';
        global $client;

        $client = new JAXL(array(
            'jid' => 'user@localhost',
            'pass' => 'password',
            'log_level' => JAXL_INFO
        ));

        $client->add_cb('on_stream_features', function($stanza)  {
            global $client,$thisObj;
            $client->send_chat_msg('otherUser@localhost','Message');  
        });

       $client->add_cb('on_message_send',function(){  //some thing like this
         //some code
       });
}
like image 433
superuser Avatar asked Aug 16 '26 00:08

superuser


1 Answers

Jaxl library currently doesn't support such callbacks. This is because when you call $client->send_chat_msg(), XMPPStream queues XMPPMsg object in the output buffer of underlying JAXLSocketClient. Output buffers are flushed as and when socket is ready for write.

Before queuing all XMPPStanza's are serialised (to_string()) by XMPPStream, thus underlying JAXLSocketClient output buffers have no knowledge about which stanza is being flushed over the write ready socket. As a result no such callbacks are currently possible.

There are non-authoritative ways of performing check about delivery status of your message e.g. is the output buffer empty? But this is tricky and not a perfect solution.

Perfect way to implement such callbacks will be to maintain output buffers within the context of XMPPStream, which should then be notified about underlying socket write ready state, finally before flushing stanza's over the socket, XMPPStream can execute these callbacks. Unfortunately, this is not how the library is designed. Though, possibilities are that such callbacks might get supported in future version of the library.

like image 91
Abhinav Singh Avatar answered Aug 18 '26 02:08

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!