本文整理汇总了Java中org.jivesoftware.openfire.session.ClientSession.getDefaultList方法的典型用法代码示例。如果您正苦于以下问题:Java ClientSession.getDefaultList方法的具体用法?Java ClientSession.getDefaultList怎么用?Java ClientSession.getDefaultList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.session.ClientSession
的用法示例。
在下文中一共展示了ClientSession.getDefaultList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: declineDefaultList
import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
/**
* User has specified that there is no default list that should be used for this user.
*
* @param packet IQ packet declining default list for all sessions.
* @param from sender of the IQ packet.
* @return acknowledge of success.
*/
private IQ declineDefaultList(IQ packet, JID from) {
IQ result = IQ.createResultIQ(packet);
Element childElement = packet.getChildElement().createCopy();
result.setChildElement(childElement);
if (sessionManager.getSessionCount(from.getNode()) > 1) {
// Current default list is being used by more than one session
result.setError(PacketError.Condition.conflict);
}
else {
// Get the user session
ClientSession session = sessionManager.getSession(from);
// Check if a default list was already defined
if (session.getDefaultList() != null) {
// Set the existing default list as non-default
session.getDefaultList().setDefaultList(false);
// Update the database with the new list state
provider.updatePrivacyList(from.getNode(), session.getDefaultList());
session.setDefaultList(null);
}
}
return result;
}
示例2: setDefaultList
import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
/**
* User has specified a new default list that should be used for all session.
*
* @param packet IQ packet setting new default list for all sessions.
* @param from sender of the IQ packet.
* @param listName name of the new default list for all sessions.
* @return acknowledge of success.
*/
private IQ setDefaultList(IQ packet, JID from, String listName) {
IQ result = IQ.createResultIQ(packet);
Element childElement = packet.getChildElement().createCopy();
result.setChildElement(childElement);
if (sessionManager.getSessionCount(from.getNode()) > 1) {
// Current default list is being used by more than one session
result.setError(PacketError.Condition.conflict);
}
else {
// Get the list
PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
if (list != null) {
// Get the user session
ClientSession session = sessionManager.getSession(from);
PrivacyList oldDefaultList = session.getDefaultList();
manager.changeDefaultList(from.getNode(), list, oldDefaultList);
// Set the new default list for this session (the only existing session)
session.setDefaultList(list);
}
else {
// List not found
result.setError(PacketError.Condition.item_not_found);
}
}
return result;
}