JAXL library – List of available hooks for various XMPP events

Jaxl 2.x provides an event mechanism using which developers can register callbacks for various xmpp events inside their application code. This blog post will demonstrate how to register callbacks for required xmpp events and go through a list of all available hooks. Finally, we will discuss parameters that are passed to called back methods by Jaxl core.

Registering callback on XMPP events
Applications can register callback for various XMPP events. Jaxl core will then callback application methods (with 2 parameters) every time associated XMPP event occurs. Shown below are some sample examples for registering callbacks.

When application callback’d method is a function:

function postAuth($payload, $jaxl) {

$jaxl->addPlugin('jaxl_post_auth', 'postAuth');

When application callback’d method is a public static method of a class:

class MyXMPPApp {
    public static function postAuth($payload, $jaxl) {

$jaxl->addPlugin('jaxl_post_auth', array('MyXMPPApp', 'postAuth'));

When application callback’d method is a public method inside a class:

class MyXMPPApp {
    function postAuth($payload, $jaxl) {

$MyXMPPApp = new MyXMPPApp();
$jaxl->addPlugin('jaxl_post_auth', array($MyXMPPApp, 'postAuth'));

In all the above examples jaxl_post_auth is one of the available hook for registering callbacks.

List of available hooks
Below is a complete list of available hooks in order of their occurrence within a Jaxl instance life cycle:

Hooks for events related to instance connection and authentication steps in various modes:

  • jaxl_post_connect
  • jaxl_get_auth_mech
  • jaxl_get_facebook_key
  • jaxl_post_auth_failure
  • jaxl_post_auth
  • jaxl_post_handshake
  • jaxl_pre_shutdown
  • jaxl_post_disconnect
  • jaxl_get_empty_body

Hooks for events related to XMPP stream and stanza’s:

  • jaxl_get_stream_error
  • jaxl_get_presence
  • jaxl_get_message
  • jaxl_get_iq_get
  • jaxl_get_iq_set
  • jaxl_get_iq_error
  • jaxl_send_message
  • jaxl_send_presence

Hooks for events related to reading/writing of XMPP packets and internal packet routing:

  • jaxl_get_xml
  • jaxl_send_xml
  • jaxl_send_body
  • jaxl_pre_handler
  • jaxl_post_handler

TO-DO: Update when every hook is called inside your application life cycle and list of parameters passed for each callback. As of now you can var_dump($payload); inside your callback method.

6 thoughts on “JAXL library – List of available hooks for various XMPP events”

  1. hi abhi,
    i downloaded jaxl_2.1.2 and run example:componentbot.php on ubuntu and mac os x,i get this error:[[XMPP]] Unable to open socket to the jabber host.
    can u give me some advices?

  2. Hi Abhinav,

    I downloaded the latest stable jaxl from http://jaxl.googlecode.com/files/jaxl-2.1.2-rc1.zip . I am trying to use the XEP-0133 implementation to create/delete users in a ejabberd instance. However I see that the code in core/jaxl.parser.php is not complete. There is code in xep/jaxl.0133.php which expects a datastructure parsed out in jaxl.parser.php, but the parsing code isnt there. I am afraid some code wasnt checked in. For instance in the parser, I dont see any XSLT in the ‘iq’ sections of the $tagMap for fields etc. I thought it would get parsed out when you grab direct XML out of the forms and responses, but it didnt. Is the code complete or is there code that hasnt been published yet ?

    Thanks in advance,

  3. Oh .. I guess I should have said XPATH instead of XSLT.. Sorry..

    About the problem, here’s a little more detail .. What happens is, the xmpp server sends back the form , there is code that is supposed to parse the form, and fill out the fields required. The problem is the parsing doesnt handle these fields.

  4. 1341984050 [INFO]: Connecting to tcp://talk.google.com:80 1341984050 [VERBOSE]: Socket is ready; send it. 1341984050 [VERBOSE]: SENT: 1341984050 [VERBOSE]: Successfully sent 114 bytes. 1341984050 [VERBOSE]: RECV: 1341984050 [VERBOSE]: RECV: X-GOOGLE-TOKENX-OAUTH2 1341984050 [DEBUG]: Calling features_handler 1341984050 [INFO]: Attempting Auth… 1341984050 [VERBOSE]: Socket is ready; send it. 1341984050 [VERBOSE]: SENT: AHNocmkAZGltZGlt 1341984050 [VERBOSE]: Successfully sent 88 bytes. 1341984050 [VERBOSE]: RECV: 1341984050 [DEBUG]: Calling sasl_failure_handler 1341984050 [ERROR]: Auth failed! 1341984050 [VERBOSE]: Disconnecting… 1341984050 [VERBOSE]: Socket is ready; send it. 1341984050 [VERBOSE]: SENT: 1341984050 [VERBOSE]: Successfully sent 16 bytes. 1341984050 [VERBOSE]: Error on stream_select() Auth failed! any solution for this??

Comments are closed.