[JDEV] Doc on MIO API for Transport dev available?---> Modul e API or Transport API exists ?
DJ Adams
dj.adams at pobox.com
Tue Jun 19 18:35:48 CDT 2001
On Tue, Jun 19, 2001 at 05:52:33PM +0200, Riviere Stéphane wrote:
> Hi,
>
> Thanks for the answer, the Jabberd API will be very helpful !
> My main question is (in fact) : when the server loads a module, which
> function(s) does it call on that module. I suppose there must be some sort
> of Module API :-)
>
> I watched at the different modules and saw they all have a function with a
> mreturn myfunction (jsmi si)
> prototype. That function registers functions (using the js_mapi_register or
> js_mapi_session) which have a protype like :
> mreturn myhandlingfunction (mapi m, void *arg)
The JSM modules all follow the same pattern. The function that is called
when the module is loaded is the one specified in the load part of the
configuration, e.g.
<load main="jsm">
<jsm>./jsm/jsm.so</jsm>
<mod_echo>./jsm/jsm.so</mod_echo>
<mod_roster>./jsm/jsm.so</mod_roster>
<mod_time>./jsm/jsm.so</mod_time>
...
the tagname (e.g. 'mod_time') is the name of the function ('mod_time()')
called.
This function usually is to be found, by convention, at the end of the
source file, and returns a void:
void mod_xyz(jsmi si)
{
js_mapi_register(e_ ...)
...
}
This function registers handlers for the master events (e_SERVER,
e_AUTH, and so on). The e_SESSION master event has 'sub-events'
es_IN, es_OUT and so on (see jsm/jsm.h), and handlers for these
sub-events (session events) are set up in a beautifully fractal
way - the handler function for the e_SESSION event actually sets
handlers for the es_* events using js_mapi_session() :
mreturn xyz_abc(...)
{
js_mapi_session(es_ ...)
}
The rest of the functions do the actual work. You might want to
have a look at jsm/modules/mod_example.c as it's got some useful
comments in the code.
Good luck!
dj
More information about the JDev
mailing list