I have set up a chat setting using Pidgin and Ejabberd. I have written a custom module in ejabberd using the user_send_packet
hook:
ejabberd_hooks:add(user_send_packet, _Host, ?MODULE,
myMessage, 95),
The function myMessage
is as follows:
myMessage({Packet, C2SState})->
PacketType=xmpp:get_name(Packet),
case PacketType of
<<"iq">>->
ok;
<<"presence">>->
ok;
<<"message">>->
Sum=2+2,
?INFO_MSG("Sum is ~p~n",[Sum])
end,
{Packet,C2SState}.
Basically what this function does is that whenever someone sends a chat message say "hello there"
, the value of Sum gets calculated and printed on the server and its logs and the message "hello there"
is sent to the second user.
But now I want send the value of Sum along with the message "hello there" to the second user for example:
"hello there Sum is 4"
Can anyone help me out with this?