Ejabberd send message from hooks
I have hook handler in my code:
ejabberd_hooks:add(sm_register_connection_hook, "localhost", ?MODULE, on_register, 80),
on_register(SID, JID, INFO) ->
{_, _, _, _, Name, _, _} = JID,
ok.
For example i want to send this Name to gen_server, how can i send message to gen_server for example from this hook with Name? How can i know gen_server's pid in开发者_如何学Cside on_register?
Thank you.
The on_register is a basic module function of ?MODULE. If the gen_server is a singleton server, you can send the name to it using gen_server:call(?MODULE, {name, Name}) or gen_server:cast(?MODULE, {name, Name}).
So the result would look like:
on_register(SID, JID, INFO) ->
{_, _, _, _, Name, _, _} = JID,
gen_server:call(?MODULE, {name, Name}),
ok.
精彩评论