本文整理汇总了Java中org.jivesoftware.smackx.muc.MultiUserChat.getOccupant方法的典型用法代码示例。如果您正苦于以下问题:Java MultiUserChat.getOccupant方法的具体用法?Java MultiUserChat.getOccupant怎么用?Java MultiUserChat.getOccupant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.muc.MultiUserChat
的用法示例。
在下文中一共展示了MultiUserChat.getOccupant方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: joined
import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
@Override
public void joined(EntityFullJid entityFullJid) {
XmppAddress xa = new XmppAddress(entityFullJid.toString());
ChatGroup chatGroup = mChatGroupManager.getChatGroup(xa);
MultiUserChat muc = mChatGroupManager.getMultiUserChat(entityFullJid.asBareJid().toString());
Occupant occupant = muc.getOccupant(entityFullJid);
Jid jidSource = (occupant != null) ? occupant.getJid() : null;
if (jidSource != null)
xa = new XmppAddress(jidSource.toString());
else
xa = new XmppAddress(entityFullJid.toString());
Contact mucContact = new Contact(xa, xa.getUser(), Imps.Contacts.TYPE_NORMAL);
chatGroup.notifyMemberJoined(entityFullJid.toString(),mucContact);
if (occupant != null) {
chatGroup.notifyMemberRoleUpdate(mucContact, occupant.getRole().name(), occupant.getAffiliation().toString());
}
}
示例2: getResourcePrivileges
import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public Privilege getResourcePrivileges(Resource resource, Resource target){
MultiUserChat chatroom = MultiUserChatManager.getInstanceFor(connection).getMultiUserChat(resource.getAddress());
String occupantAddress = resource.getAddress()+"/"+resource.getName();
Occupant o = chatroom.getOccupant(occupantAddress);
switch(o.getRole()){
case moderator: return Privilege.MODERATOR;
default: return Privilege.USER;
}
}
示例3: xmppMUCOccupants2mcrOccupants
import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public List<BuddyGroup> xmppMUCOccupants2mcrOccupants(XMPPServiceInternal service, MultiUserChat muc, boolean loadIcons) {
List<BuddyGroup> groups = new ArrayList<BuddyGroup>();
String ownerJid = service.getOnlineInfo().getProtocolUid();
BuddyGroup moderators = new BuddyGroup(Integer.toString(2), ownerJid, service.getOnlineInfo().getServiceId());
BuddyGroup participants = new BuddyGroup(Integer.toString(5), ownerJid, service.getOnlineInfo().getServiceId());
BuddyGroup other = new BuddyGroup(Integer.toString(7), ownerJid, service.getOnlineInfo().getServiceId());
BuddyGroup all = new BuddyGroup(Integer.toString(8), ownerJid, service.getOnlineInfo().getServiceId());
//TODO
moderators.setName("Moderators");
participants.setName("Participants");
other.setName("Other");
all.setName("All");
Map<String, Buddy> buddies = new HashMap<String, Buddy>();
Iterator<String> it = muc.getOccupants();
for (;it.hasNext();){
String occupant = it.next();
String buddyId;
Occupant occu = muc.getOccupant(occupant);
if (occu != null && occu.getJid() != null){
buddyId = normalizeJID(occu.getJid());
if (loadIcons){
try {
service.loadCard(buddyId);
} catch (Exception e) {
Logger.log(e);
}
}
} else {
buddyId = occupant;
}
Buddy buddy = new Buddy(buddyId, ownerJid, XMPPApiConstants.PROTOCOL_NAME, service.getOnlineInfo().getServiceId());
buddy.setName(buddyId.equals(occupant) ? StringUtils.parseResource(occupant) : occu.getNick());
buddy.getOnlineInfo().getFeatures().putByte(ApiConstants.FEATURE_STATUS, xmppPresence2UserStatus(muc.getOccupantPresence(occupant)));
buddies.put(buddy.getProtocolUid(), buddy);
buddy.setId(buddyId.hashCode());
all.getBuddyList().add(buddy);
}
try {
fillMUCGroup(muc.getParticipants(), participants, buddies);
fillMUCGroup(muc.getModerators(), moderators, buddies);
other.getBuddyList().addAll(buddies.values());
groups.add(moderators);
groups.add(participants);
groups.add(other);
} catch (Exception e1) {
Logger.log(e1);
}
if (groups.size() < 1){
groups.add(all);
}
return groups;
}