2
我很努力地傾聽聯繫人的更新VCard。我試圖通過發送一個自定義狀態來執行此操作,這個自定義狀態包含一些自定義信息,同時更新VCard.from調試的輸出,我發現,無論何時發送這樣的自定義狀態,它的聯繫人都會收到狀態節。不幸的是,當聯繫人的packetListener無法檢測到傳入的數據包,然後添加到連接的所有偵聽器似乎都已被刪除時,儘管調試仍可正常工作,但以前可檢測到的其他數據包 仍無法偵聽。 我的一些代碼片段就像這樣的:如何發送和收聽與asmack庫的自定義xmpp存在數據包
// to update VCard
mVCard.load(mXMPPConnection);
mVCard.setField(XmppUserInfo.tagHeadIcon, userInfo.getHeadIconUrl());
mVCard.setField(XmppUserInfo.tagGender, userInfo.getGender());
mVCard.setField(XmppUserInfo.tagNickname,userInfo.getNickname());
mVCard.setField(XmppUserInfo.tagAccount, userInfo.getAccount());
mVCard.setField(XmppUserInfo.tagSignnature, userInfo.getSignnature());
mVCard.save(mXMPPConnection);
// to send custom presence to subscribers to renew infomation
Presence presence = new Presence(Type.available);
presence.addExtension(new UserInfoExtension(userInfo));
mXMPPConnection.sendPacket(presence);
,我的聽衆是這樣的:
//add Listener
PacketListener packetListener = new PacketListener() {
@Override
public void processPacket(Packet packet) {
if(null != packet){
Log.i(TAG,"UserInfo is being updated");
Log.i(TAG, "the packet is " +packet.toXML());
}
}
}
};
xmppConnection.addPacketListener(packetListener, new PacketFilter() {
@Override
public boolean accept(Packet p) {
return true;
}
});
,但我不能說在日誌中prescen節,雖然我可以從輸出接收存在的調試。有誰能夠幫助我?非常感謝。
的receieved存在是這樣的:
<presence id="AL4As-4" from="[email protected]/ad9a8862" to="[email protected]">
<user xmlns="kascend:video:xmpp:userinfo">
<info account="133787245" gender="f" signnature="wwwwwww" nickname="bbbb"/>
</user>
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.igniterealtime.org/projects/smack/" ver="O1jiM4C3yPnCFLp9hBZUn4AgVXs="/></presence>