Article - Talk ejabberd module development
Introduction
ejabberd internal modules works as plugins. Each module is an erlang module with a name beginning with “mod_”. If you don’t already know Erlang, you should also take a look at this doc.
API of the module
All the internal modules must use the “gen_mod” behavior.
It must provide the following API:
start(Host, Opts) -> ok
stop(Host) -> ok
* Host = string()
* Opts = [{Name, Value}]
* Name = Value = string()
Host is the name of the virtual host running the module. The start/2 and stop/1 functions are called for each virtual host at start and stop time of the server.
Opts is a lists of options set in the configuration file for the module. They can be retrieved with the gen mod:get opt/3 function.
ejabberd API
The modules interact with ejabberd using one or several of the following mechanisms:
- ejabberd core modules
- ejabberd events and hooks
- ejabberd IQ handlers
- ejabberd route table
- ejabberd HTTP request handlers
Running an internal module as an external module
ejabberd internal modules using only the route table can also be used as external modules conform to XEP-0114 with epeios, and thus, they can be used with any other XEP-0114 compliant XMPP servers.
