Documentation for ejabberd hooks?

Hooks seem very convenient to extend ejabberd functionality.

There are a bunch of ejabberd hooks mentioned by the creators, but it's hard to know which one should be used when, apart from a few.

can anyone share some details from their experience that explains what a particular hook does?

+7
erlang hook xmpp ejabberd
source share
2 answers

There will be certain events on which you would like to initiate some action. Hooks associate your code with some ejabberd components when an event occurs. You can write your own code (a.ka. Event handler) and integrate it with ejabberd using the HOOK.

  • filter_packet . This hook is triggered by ejabberd_router as soon as the packet is routed through ejaberd_router: route / 3. ejabberd_c2s calls it after receiving the packet from ejabberd_receiver (i.e. the socket), and several modules use it to send responses and errors.
  • offline_message_hook : when ejabberd routes the side and receiver, it is disconnected.
  • user_receive_packet . The hook starts immediately after sending the packet to the user.
+1
source share

● sm_remove_connection_hook and

● sm_register_connection_hook

also very handy for capturing when the user disconnects - and online.

0
source share