Search code examples
ejabberdejabberd-moduleejabberd-hooks

When does the user_receive_packet hook gets started/triggered


I am using hooks in ejabberd to create a custom module and have used user_send_packet hook till now.I wanted to implement a custom functionality on ejabberd server as soon as (and after) the packet is sent to the client from the server. I am thinking about using user_receive_packet hook but I am a bit confused regarding the time when it gets triggered or started.

Does it start or gets triggered just before the packet is sent to client or does it starts after the packet is sent to the client.

And in case if it starts or gets triggered before the the packet is sent, then in that case what happens to the packet being sent to the client, I mean does the packet wait for the module implementing user_receive_packet to finish and then goes to the client or it simple is not affected?

Can anyone help me out here?


Solution

  • I am trying to answer the question so that it may help somebody in future.

    The user_receive_packet hook is called before the packet is sent to the user. It returns (Packet,State) (irrespective of the fact that packet has changed or not) or (drop,State) in case the packet is silently dropped.