2

我正在努力收听联系人对 VCard 的更新。我试图通过在更新 VCard 时发送带有一些自定义信息的自定义存在来做到这一点。从调试的输出中,我发现,每当发送这样的自定义存在时,它的联系人都会收到存在节。不幸的是,当联系人的 packetListener 无法检测到传入的数据包,然后添加到连接的所有侦听器似乎已被删除,即之前可以检测到的其他数据包无法侦听,但调试仍然可以正常工作。我的一些代码片段就像这样:

// 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 节,尽管我可以从调试的输出中接收到存在。有谁能够帮我?非常感谢。

收到的出席是这样的:

<presence id="AL4As-4" from="20298509@openfire/ad9a8862" to="20298468@openfire">
<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>
4

1 回答 1

0

很抱歉误导了你。最后发现问题是由我的扩展提供程序中的错误引起的,这可能会使程序陷入无限循环。我修复了那个错误,现在一切正常。

于 2013-01-22T14:03:15.237 回答