Revision [317]

Last edited on 2005-10-06 14:39:25 by KogAdmin [misc edits]
Additions:
//This file is also available on [[http://wiki.atheme.org/modules:event_hooking Atheme's Wiki]]//
<<NOTE: examples are from my memoserv system
ACHTUNG: I also have written far more C# than Java, so my documentation may use terms that are not from the C world, sorry<< ::c::
Deletions:
<<NOTE: examples are from my memoserv system << ::c::
<<ACHTUNG: I also have written far more C# than Java, so my documentation may use terms that are not from the C world, sorry<< ::c::


Revision [316]

Edited on 2005-10-06 13:58:13 by KogAdmin [added sig]
Additions:
<<ACHTUNG: I also have written far more C# than Java, so my documentation may use terms that are not from the C world, sorry<< ::c::
Certain functions in Atheme will fire "events" to the rest of the system upon their completion. For example, identify calls
hook_call_event("user_identify", mu); //char* and myuser_t*
on a successful identification. I wanted to consume this hook because I wanted my [[AthemeMemoServ MemoServ]] to notice you of new memos on login. Using this hook as I did below is a far nicer solution than putting code in both userserv and nickserv, because potentially any service for ID that gets built will fire that event.
static void on_user_identify(void *vptr); //ah yes... void pointer hack, kinda like passing Object in java
All hooks pass a myuser_t (as you can see from the second param in hook_call_event above)
hook_add_event("user_identify"); //we want user_identify to know we consume it
hook_add_hook("user_identify", on_user_identify); //we want to consume it with on_user_identify
Deletions:
Certain functions in Atheme will fire "events" to the rest of the system upon their completion. In one case I wanted to add a bit to MemoServ to make it notice you of any new memos on login. At first I put code in login/identify for the respective authentication services (nickserv/userserv), but realized there was probably a better way... Here it is:
static void on_user_identify(void *vptr);
hook_add_event("user_identify");
hook_add_hook("user_identify", on_user_identify);


Revision [315]

The oldest known version of this page was created on 2005-10-06 13:52:40 by KogAdmin [added sig]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki