【发布时间】:2015-06-08 11:21:27
【问题描述】:
在我的聊天应用程序中。我正在使用 Smack 库和 Openfire 服务器。我想屏蔽特定用户。
我正在尝试实现一个功能,它会阻止特定用户,但它对我不起作用。它不会给出任何错误或异常。
我的代码是
public void XMPPAddNewPrivacyList(XMPPConnection connection, String userName) {
String listName = "newList";
List<PrivacyItem> privacyItems = new Vector<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.toString(),
false, 1);
item.setValue(userName);
privacyItems.add(item);
// Create the new list.
try {
PrivacyListManager privacyManager = new PrivacyListManager(connection);
privacyManager = PrivacyListManager
.getInstanceFor(connection);
privacyManager.createPrivacyList(listName, privacyItems);
} catch (XMPPException e) {
System.out.println("PRIVACY_ERROR: " + e);
}
}
XMPPAddNewPrivacyList(XmppConnection.getInstance().getConnection(),
"91xxxxxxxxxx@xxx.com");
【问题讨论】:
-
你使用的是什么版本的 smack 和 openfire???
-
你的问题解决了吗???
-
No this PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid, userName,false, 1l) 构造函数不在 PrivacyItem 类中
-
你使用的是哪个版本的 smack 和 openfire???
-
qsmack 的状态请尝试 Smack 4.1.0,它比 qsmack 更稳定,功能更多,您可以参考此获取更多信息github.com/igniterealtime/Smack/wiki/…