[ejabberd] How to add a custom event?
jason.liuxi at gmail.com
Fri Jan 22 05:19:44 MSK 2010
I checked the code and finally I understand.
the event function prototype is defined scattered al around.
By calling ejabberd_hook:run to define the event prototype.
I posted it here for who got the same problem as I do, though it seems
2010/1/21 Xi Liu <jason.liuxi at gmail.com>
> Hi friends:
> I wanna add a module in ejabberd in order to create a sub muc room for
> every muc room users create.
> I write a module beavioring gen_mod containing start, stop and a function
> to create a room everything the same with the original room except the
> name.And I also modify the config file to start my module with
> ejabberd.Since there is no existing events fit my need, so I try to create a
> new event and hook the function to the event in my own modules's start().
> and unload it in stop()
> I intend to add a event in the do_route function in module mod_muc.erl.and
> modify the room name in the Packet,then call do_route1 again after the
> original do_route1 call in do_route.
> I can achive this simplely add lines of code in mod_muc just call do_route1
> again.But I want to use the hook and event facility.Here is my plan: I
> register a event and triger this event by calling
> ejabberd:hooks:run(event_name, XXX). and this will call the function in my
> own module. So I need to pass some arguments like Packet to my function. How
> to specify the arguments and where to add a user-defined event?
> I checked the source tring to find out where the original events like
> set_presence_hook(User, Server, Resource, Packet) -> none is defined, but
> ther are only codes about add, delete and run.
> Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ejabberd