Search code examples
ejabberdejabberd-moduleejabberd-hooks

correct syntax for the hook user_receive_packet in ejabberd-18.12?


Current code :

user_receive_packet({Packet, C2SState}) ->

    ?INFO_MSG("~p.", [Packet]),
    {Packet, C2SState}.

Getting error when the hook is invoked:

[error] Hook user_receive_packet crashed when running... 
** Reason = {error,function_clause...

I guess the function arguments are wrong. What should be the correct syntax ? I am using ejabberd-18.12


Solution

  • Correct Syntax:

    user_receive_packet({Packet, #{jid := JID} = C2SState}) ->
    
        {Packet, C2SState}.