ejabberd-自定义iq处理程序 [英] ejabberd - custom iq handlers
本文介绍了ejabberd-自定义iq处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了简单的模块。这是代码
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...">>}]}]}.
当我使用strophe.js发出请求时 var iq = $ iq({类型:获取,到:某个主机})。c('查询',{xmlns:'jabber:iq:conversations'}); connection.sendIQ(iq);
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
推荐答案
在最近的ejabberd版本中,请勿使用xmlelement元组,正确的代码应如下所示: :
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...">>}]}]}.
这篇关于ejabberd-自定义iq处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文