我想自定义IQ从Android应用程序发送到ejabberd服务器,我有这个下面的类
public class IQCustom extends IQ {
public final static String childElementName = "query";
public final static String childElementNamespace = "jabber:iq:conversations";
public IQCustom(String userFrom, String server)
{
super( childElementName, childElementNamespace );
this.setType(Type.get);
setTo( server );
setFrom( userFrom );
}
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
xml.rightAngleBracket();
xml.halfOpenElement("abc");
xml.attribute("op","sum");
xml.rightAngleBracket();
xml.closeElement("abc");
return xml;
}
}
而这些都是智商日志我得到:
D/SMACK: SENT (1): <iq to=‘example.com' id='BQ8wt-16' type='get'><query xmlns='jabber:iq:conversations'><abc op='sum'></abc></query></iq>
D/SMACK: RECV (1): <iq to='testing7@example.com/Smack' from='example.com' type='get' id='BQ8wt-16'><query xmlns='jabber:iq:conversations'><abc op='sum'/></query></iq>
D/SMACK: RECV (1): <r xmlns='urn:xmpp:sm:3'/>
D/SMACK: SENT (1): <iq to='example.com' id='BQ8wt-16' type='error'><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
D/SMACK: SENT (1): <r xmlns='urn:xmpp:sm:3'/>
D/SMACK: SENT (1): <a xmlns='urn:xmpp:sm:3' h='4'/>
D/SMACK: RECV (1): <a h='5' xmlns='urn:xmpp:sm:3'/>
我明白第一的原因收到的智商,我得到,但我不明白的智商的原因:
D/SMACK: SENT (1): <iq to='example.com' id='BQ8wt-16' type='error'><error type='cancel'><feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
编辑
这是应该当我将上面的查询采取行动的模块:
-module(mod_conversations).
-behaviour(gen_mod).
%% ====================================================================
%% API functions
%% ====================================================================
-export([start/2, stop/1, process_local_iq/3]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
-define(NS_IQ_CUSTOM, <<"jabber:iq:conversations">>).
start(Host, _) ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM, ?MODULE, process_local_iq, one_queue),
?INFO_MSG("Inside mod_conversation",[]),
ok.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM),
ok.
process_local_iq(From,_ ,IQ) ->
From,
?INFO_MSG("Inside mod_conversation, IQ is ~p~n ",[IQ]),
Sum = 2+2,
IQ.
而且里面gen_iq_handler()我看到的处理程序已经登记的,所以,现在是什么实现该特性的意思是我很困惑。
我只希望在应对智商发送和的值到客户端,我应该怎样准确地注册这个功能,我怎么能发送从这个模块客户端/用户没有任何错误IQ的一个智商回应?