大家好,我正在使用这些代码行来获取使用smack的对话列表
@Override
protected Void doInBackground(String... strings) {
final ArrayList<UsersData> users
= UsersManager.getInstance().getUsers();
int count = 0;
while(count < users.size()) {
try {
Thread.sleep(500);
final String jid
= users.get(count).getUserJID();
IQ iq = new IQ() {
@Override
public String getChildElementXML() {
String list = "<list xmlns='urn:xmpp:archive'"+
"with='"+jid+"'>"+
"<set xmlns='http://jabber.org/protocol/rsm'>"+
"<max>30</max></set></list>";
return list;
}
};
iq.setType(IQ.Type.GET);
iq.setPacketID(jid+System.currentTimeMillis());
service.getXmppConnection().sendPacket(iq);
Log.v("XmppAsyncHistory", "IQ List sent!");
} catch (InterruptedException e) {
e.printStackTrace();
}
count++;
}
return null;
}
我添加了我的iq提供商。
provider.addIQProvider("list", "urn:xmpp:archive", new ListIQProvider());
我得到这个节的回复。
D/SMACK(11130): 10:34:30 PM RCV (1096010080):
<iq type="result"
id="24@suitmedia1375112070174"
to="17@suitmedia/Smack"><list xmlns="urn:xmpp:archive">
chat with="24@suitmedia"
start="2013-07-25T09:57:04.121Z"/>
<chat with="24@suitmedia"
start="2013-07-25T11:08:28.997Z"/>
<chat with="24@suitmedia"
start="2013-07-29T09:29:18.295Z"/>
<chat with="24@suitmedia"
start="2013-07-29T07:47:29.841Z"/>
<set xmlns="http://jabber.org/protocol/rsm">
<first index="0">184</first><last>216</last>
<count>4</count></set></list></iq>
正如您所看到的,它不是最新的对话,而是最早的对话,分别是25/07至29/07
我想问的是这些标签是什么意思? 184216 我怎样才能最近获得会话列表顺序?
谢谢!
答案 0 :(得分:0)
您应该使用当前时间向“list”元素添加属性“end”。 XML将如下所示:
<iq type='get' xmlns='jabber:client'><list xmlns='urn:xmpp:archive' end='2014-05-28T08:48:56+08:00' with='somebody@somesite'><set xmlns='http://jabber.org/protocol/rsm'><max>10</max><before/></set></list></iq>