问题
I have created simple module. here is the code
-module(mod_conversations).
-behaviour(gen_mod).
-export([start/2, stop/1, process_local_iq/3]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("jlib.hrl").
-define(IQ_CUSTOM, <<"jabber:iq:conversations">>).
start(Host, _) ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?IQ_CUSTOM, ?MODULE, process_local_iq, one_queue),
ok.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?IQ_CUSTOM),
ok.
process_local_iq(From,_ ,IQ) ->
IQ#iq{type = result, sub_el = [{xmlelement, <<"value">>, [], [{xmlcdata, <<"Testing...">>}]}]}.
When i make request with strophe.js var iq = $iq({type: 'get', to: 'some host'}).c('query', {xmlns: 'jabber:iq:conversations'}); connection.sendIQ(iq);
server disconnects me.I have tried to find simillar issues but some of them was more problematic. please help me to solve this issue
回答1:
You must not use xmlelement tuples in recent ejabberd versions, the correct code should look like this:
IQ#iq{type = result,
sub_el = [#xmlel{name = <<"value">>,
children = [{xmlcdata, <<"Testing...">>}]}]}.
来源:https://stackoverflow.com/questions/41506560/ejabberd-custom-iq-handlers