I am using ejabberd-2.1.2 server. How can I add new name space to existing ejabberd server. I would like to add name space ('http://jabber.org/protocol/rosterx') XEP-0144 Roster Item exchange.
Than开发者_JAVA百科ks, sathi.
Create a module, name it something like mod_rosterx.erl
. Add it into your ejabberd.cfg
file.
The contents of this file should be something like the following. You'll need to actually write your code in the process_local_iq
functions. Also, this will handle IS stanzas addressed to the server, not addressed to other clients. Adjust as needed!
-module(mod_rosterx).
-behavior(gen_mod).
-export([start/2, stop/1, process_local_iq/3]).
-include("ejabberd/src/ejabberd.hrl").
-include("ejabberd/src/jlib.hrl").
-define(NS_ROSTERX, "http://jabber.org/protocol/rosterx").
start(Host, Opts) ->
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
mod_disco:register_feature(Host, ?NS_ROSTERX),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_ROSTERX, ?MODULE, process_local_iq, IQDisc).
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_ROSTERX).
process_local_iq(From, To, {iq, ID, set, NS, Language, SubElement}) ->
{iq, ID, error, NS, Language, []};
process_local_iq(_, _, {iq, ID, get, NS, Language, SubElement}) ->
{iq, ID, error, NS, Language, []}.
精彩评论