问题描述
我正在尝试从android应用程序向ejabberd服务器发送自定义IQ,并且我有以下课程
I am trying to send a custom IQ to ejabberd server from android app and I have this following class
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;
}
}
这些是我得到的IQ日志:
and these are the IQ logs I am getting:
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='[email protected]/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'/>
我了解我第一次收到智商的原因,但我不明白智商的原因:
I understood the reason of first receive iq that I getting but I didn’t understand the reason for the iq:
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>
编辑
这是我发送上述查询时应该起作用的模块:
This is the module which is supposed to act when I send the above query:
-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()内部,我看到处理程序已经注册,所以现在我很困惑,实现此功能的含义是什么.
And Inside gen_iq_handler() I saw that handler were already registered, So I am confused now that what does implementing the feature mean.
我只想将响应iq中的Sum值发送给客户端,为此我应该如何准确地注册此功能,以及如何从该模块向客户端/用户发送iq响应而不会出现错误iq?
I only want to send the value of Sum in a responding iq to the client, for that how exactly should I register this feature and how can i send a iq response from this module to the client/user without any error iq's?
推荐答案
您是否使用ns xmpp节实现了该功能?
Have you implemented the feature with ns xmpp-stanzas?
这篇关于未实施响应功能的含义是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!