XMPP结果智商问题解析 [英] XMPP IQ result parsing issue

查看:160
本文介绍了XMPP结果智商问题解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Eclipse,Java和asmack一个XMPP聊天客户端应用程序。使用教程和许多许多的谷歌搜索我设法好友列表的工作,实际也聊着工作正常。
 我的问题是寻找更多的哥们添加到我的联系人列表中。发送XML在这里举例说明: http://xmpp.org/extensions/xep-0055.html
 我的要求是:

I am building a XMPP chat client app with eclipse, java and asmack. Using tutorials and many many google searches I managed to get the buddy list working, actual chatting also works fine. My problem is with searching for more buddies to add to my contacts list. The XML to send is exemplified here : http://xmpp.org/extensions/xep-0055.html My request is :

<iq
id="search123"
from="name3@webserv.xxx.com/name3"
to="search.xxx.zzz.com"
type="set" >
<query xmlns="jabber:iq:search" >
    <nick>
android
    </nick>
</query>
</iq>

我想我得到了/回应是这样的:

the response I thought I was getting was/is this:

<iq
id="search123"
from="search.xxx.zzz.com"
to="name3@webserv.telebroad.com/Smack"
type="result" >
</iq>

但使用
    connConfig.setDebuggerEnabled(真);
 (和在线Telnet客户端)我设法找到了该服务器实际上是正常工作,它的发送请求的结果,但我只是让你看到了什么上面。
 我一直在这4天,我的自尊是相当低的:P
 这里是我的关于智商的请求和响应code:

But using connConfig.setDebuggerEnabled(true); (and an online Telnet Client) I managed to find out that the server IS actually working correctly and it's sending the requested results, but I'm just getting what you see above. I have been at this for 4 days and my self esteem is quite low :P Here is my code concerning the IQ request and response:

Packet asdf = new Packet() {
                    @Override
                    public String toXML() {
                        return    "<iq type='set'"+
                                " from='name3@webserv.xxx.com/name3'"+
                                " to='search.xxx.zzz.com'"+
                                " id='search2'"+
                                " xml:lang='en'>"+
                              " <query xmlns='jabber:iq:search'>"+
                                " <nick>Android</nick>"+
                              " </query>"+
                            " </iq>";
                    }
                };


ChatList.connection.sendPacket(asdf);
                Log.e("packet", "request = "+ asdf.toXML());
                PacketFilter filter = new IQTypeFilter(IQ.Type.RESULT);
                ChatList.connection.addPacketListener(new PacketListener() {
                    public void processPacket(Packet packet) {
                        IQ iq = (IQ)packet;


                        Log.e("response","incoming packet : "+ packet.toXML());
                        Log.e("response","incoming packet2 : "+ packet.toString());

                    }
                }, filter);  

我试过很多TypeFilters无济于事。我很为难!

I've tried lots of TypeFilters to no avail. I'm stumped!!

底线:

1.request正在被服务器接受正确;

1.request is being accepted correctly by server;

2.server反应是正确的(所以说,调试器);

2.server response is correct(so says the debugger);

3.any response.toString toxml用于或打印出由上述类型的结果XML(无型后的实际项目='结果'>

3.any response.toString or toXML prints out the type result XML from above(without the actual items after type='result'>.

4,我上午约过期一周对我的最终版本为这个应用程序...帮助! :)

4.I am about a week overdue on my final build for this app...help! :)

推荐答案

http://stackoverflow.com/a/14214622/1688731
这...只是工作!!!!我不知道为什么。也许迭代器迭代器= row.getValues​​(JID); 的伎俩。但一切,我已经试过多次!!很多

http://stackoverflow.com/a/14214622/1688731 This...just works!!!! I have no idea why. maybe Iterator iterator = row.getValues("jid"); does the trick. But everything else, I've tried a LOT of times!!

这篇关于XMPP结果智商问题解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆