开发者

Ejabberd send message from hooks

开发者 https://www.devze.com 2023-03-25 12:32 出处:网络
I have hook handler in my code: ejabberd_hooks:add(sm_register_connection_hook, \"localhost\", ?MODULE, on_register, 80),

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.
0

精彩评论

暂无评论...
验证码 换一张
取 消