在Xmpp/Openfire中从名册中删除一个朋友 [英] Delete a Friend from Roster in Xmpp/Openfire

查看:95
本文介绍了在Xmpp/Openfire中从名册中删除一个朋友的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的聊天应用程序中.我正在使用smack库,在订阅管理"的帮助下,我已完成了将朋友添加到特定人员花名册的过程.

In my chat application. I am using smack library , with the help of Subscription Management I have done the part of adding a friend to the Roster of a particular person.

现在,我希望当某人拒绝好友请求时,我向另一个用户发送UNSUBSCRIBE PACKET的请求,而不会从另一个用户的花名册中删除该好友.它只是显示NONE订阅.

Now I want that when some person denies the friend request, I send a UNSUBSCRIBE PACKET to the other user for the same, the friend is not deleted from the roster of the other user. It simply shows NONE subscription.

代码:

Presence unsubscribe = new Presence(Presence.Type.unsubscribe);
                unsubscribe.setTo(ABC@ABC.COM);             
                connection.sendPacket(unsubscribe);

如何从朋友名册中删除该用户.我可以从openfire门户网站上做到这一点,但不知道如何从代码中做到这一点.

How can I delete the user from the Roster of the friend. I can do it from openfire portal but don't know how to do it from code.

推荐答案

Smack论坛中,此代码可能有效:

From the Smack forum, this code might work:

RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.SET);
RosterPacket.Item item  = new RosterPacket.Item("ABC@ABC.COM", null);
item.setItemType(RosterPacket.ItemType.REMOVE);
packet.addRosterItem(item);
connection.sendPacket(packet);

这篇关于在Xmpp/Openfire中从名册中删除一个朋友的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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