• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MUCRoom类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jivesoftware.openfire.muc.MUCRoom的典型用法代码示例。如果您正苦于以下问题:Java MUCRoom类的具体用法?Java MUCRoom怎么用?Java MUCRoom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MUCRoom类属于org.jivesoftware.openfire.muc包,在下文中一共展示了MUCRoom类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: canDiscoverRoom

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
private boolean canDiscoverRoom(MUCRoom room, JID senderJID) {
    // Check if locked rooms may be discovered
    if (!allowToDiscoverLockedRooms && room.isLocked()) {
        return false;
    }
    if (!room.isPublicRoom()) {
        if (!allowToDiscoverMembersOnlyRooms && room.isMembersOnly()) {
            return false;
        }
        MUCRole.Affiliation affiliation = room.getAffiliation(senderJID.asBareJID());
        if (affiliation != MUCRole.Affiliation.owner
                && affiliation != MUCRole.Affiliation.admin
                && affiliation != MUCRole.Affiliation.member) {
            return false;
        }
    }
    return true;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:19,代码来源:MultiUserChatServiceImpl.java


示例2: run

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
@Override
public void run() {
    rooms = new ArrayList<>();
    // Get all services that have local occupants and include them in the reply
    for (MultiUserChatService mucService : XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatServices()) {
        // Get rooms that have local occupants and include them in the reply
        for (MUCRoom room : mucService.getChatRooms()) {
            LocalMUCRoom localRoom = (LocalMUCRoom) room;
            Collection<MUCRole> localOccupants = new ArrayList<>();
            for (MUCRole occupant : room.getOccupants()) {
                if (occupant.isLocal()) {
                    localOccupants.add(occupant);
                }
            }
            if (!localOccupants.isEmpty()) {
                rooms.add(new RoomInfo(localRoom, localOccupants));
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:21,代码来源:GetNewMemberRoomsRequest.java


示例3: Conversation

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Constructs a new group chat conversation that is taking place in a room.
 * 
 * @param conversationManager
 *            the ConversationManager.
 * @param room
 *            the JID of the room where the conversation is taking place.
 * @param external
 *            true if the conversation includes a user on another server.
 * @param startDate
 *            the starting date of the conversation.
 */
public Conversation(ConversationManager conversationManager, JID room, boolean external, Date startDate) {
    this.conversationManager = conversationManager;
    this.participants = new ConcurrentHashMap<String, UserParticipations>();
    // Add list of existing room occupants as participants of this conversation
    MUCRoom mucRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(room).getChatRoom(room.getNode());
    if (mucRoom != null) {
        for (MUCRole role : mucRoom.getOccupants()) {
            UserParticipations userParticipations = new UserParticipations(true);
            userParticipations.addParticipation(new ConversationParticipation(startDate, role.getNickname()));
            participants.put(role.getUserAddress().toString(), userParticipations);
        }
    }
    this.room = room;
    this.external = external;
    this.startDate = startDate;
    this.lastActivity = startDate;
    // If archiving is enabled, insert the conversation into the database.
    if (conversationManager.isMetadataArchivingEnabled()) {
        try {
            insertIntoDb();
        } catch (Exception e) {
            Log.error(e.getMessage(), e);
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:38,代码来源:Conversation.java


示例4: run

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
public void run(ConversationManager conversationManager) {
    if (Type.chatMessageReceived == type) {
        conversationManager.processMessage(sender, receiver, body, "", date);
    }
    else if (Type.roomDestroyed == type) {
        conversationManager.roomConversationEnded(roomJID, date);
    }
    else if (Type.occupantJoined == type) {
        conversationManager.joinedGroupConversation(roomJID, user, nickname, date);
    }
    else if (Type.occupantLeft == type) {
        conversationManager.leftGroupConversation(roomJID, user, date);
        // If there are no more occupants then consider the group conversarion over
        MUCRoom mucRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomJID.getNode());
        if (mucRoom != null &&  mucRoom.getOccupantsCount() == 0) {
            conversationManager.roomConversationEnded(roomJID, date);
        }
    }
    else if (Type.nicknameChanged == type) {
        conversationManager.leftGroupConversation(roomJID, user, date);
        conversationManager.joinedGroupConversation(roomJID, user, nickname, new Date(date.getTime() + 1));
    }
    else if (Type.roomMessageReceived == type) {
        conversationManager.processRoomMessage(roomJID, user, nickname, body, stanza, date);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:ConversationEvent.java


示例5: occupantLeft

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
public void occupantLeft(JID roomJID, JID user) {
    // Process this event in the senior cluster member or local JVM when not in a cluster
    if (ClusterManager.isSeniorClusterMember()) {
        conversationManager.leftGroupConversation(roomJID, user, new Date());
        // If there are no more occupants then consider the group conversarion over
        MUCRoom mucRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomJID.getNode());
        if (mucRoom != null &&  mucRoom.getOccupantsCount() == 0) {
            conversationManager.roomConversationEnded(roomJID, new Date());
        }
    }
    else {
        ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
        eventsQueue.addGroupChatEvent(conversationManager.getRoomConversationKey(roomJID),
                ConversationEvent.occupantLeft(roomJID, user, new Date()));
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:GroupConversationInterceptor.java


示例6: getChatRooms

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Gets the chat rooms.
 * 
 * @param serviceName
 *            the service name
 * @param channelType
 *            the channel type
 * @param roomSearch
 *            the room search
 * @return the chat rooms
 */
public MUCRoomEntities getChatRooms(String serviceName, String channelType, String roomSearch) {
    List<MUCRoom> rooms = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName)
            .getChatRooms();

    List<MUCRoomEntity> mucRoomEntities = new ArrayList<MUCRoomEntity>();

    for (MUCRoom chatRoom : rooms) {
        if (roomSearch != null) {
            if (!chatRoom.getName().contains(roomSearch)) {
                continue;
            }
        }

        if (channelType.equals(MUCChannelType.ALL)) {
            mucRoomEntities.add(convertToMUCRoomEntity(chatRoom));
        } else if (channelType.equals(MUCChannelType.PUBLIC) && chatRoom.isPublicRoom()) {
            mucRoomEntities.add(convertToMUCRoomEntity(chatRoom));
        }
    }

    return new MUCRoomEntities(mucRoomEntities);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:34,代码来源:MUCRoomController.java


示例7: getChatRooms

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Gets the chat rooms.
 * 
 * @param serviceName
 *            the service name
 * @param channelType
 *            the channel type
 * @param roomSearch
 *            the room search
 * @return the chat rooms
 */
public MUCRoomEntities getChatRooms(String serviceName, String channelType, String roomSearch, boolean expand) {
    List<MUCRoom> rooms = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName)
            .getChatRooms();

    List<MUCRoomEntity> mucRoomEntities = new ArrayList<MUCRoomEntity>();

    for (MUCRoom chatRoom : rooms) {
        if (roomSearch != null) {
            if (!chatRoom.getName().contains(roomSearch)) {
                continue;
            }
        }

        if (channelType.equals(MUCChannelType.ALL)) {
            mucRoomEntities.add(convertToMUCRoomEntity(chatRoom, expand));
        } else if (channelType.equals(MUCChannelType.PUBLIC) && chatRoom.isPublicRoom()) {
            mucRoomEntities.add(convertToMUCRoomEntity(chatRoom, expand));
        }
    }

    return new MUCRoomEntities(mucRoomEntities);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:34,代码来源:MUCRoomController.java


示例8: getReservedNickname

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Returns the reserved room nickname for the bare JID in a given room or null if none.
 *
 * @param room the room where the user would like to obtain his reserved nickname. 
 * @param bareJID The bare jid of the user of which you'd like to obtain his reserved nickname.
 * @return the reserved room nickname for the bare JID or null if none.
 */
public static String getReservedNickname(MUCRoom room, String bareJID) {
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    String answer = null;
    try {
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(GET_RESERVED_NAME);
        pstmt.setLong(1, room.getID());
        pstmt.setString(2, bareJID);
        rs = pstmt.executeQuery();
        if (rs.next()) {
            answer = rs.getString(1);
        }
    }
    catch (SQLException sqle) {
        Log.error(sqle.getMessage(), sqle);
    }
    finally {
        DbConnectionManager.closeConnection(rs, pstmt, con);
    }
    return answer;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:31,代码来源:MUCPersistenceManager.java


示例9: updateRoomSubject

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Updates the room's subject in the database. 
 * 
 * @param room the room to update its subject in the database.
 */
public static void updateRoomSubject(MUCRoom room) {
    if (!room.isPersistent() || !room.wasSavedToDB()) {
        return;
    }

    Connection con = null;
    PreparedStatement pstmt = null;
    try {
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(UPDATE_SUBJECT);
        pstmt.setString(1, room.getSubject());
        pstmt.setLong(2, room.getID());
        pstmt.executeUpdate();
    }
    catch (SQLException sqle) {
        Log.error(sqle.getMessage(), sqle);
    }
    finally {
        DbConnectionManager.closeConnection(pstmt, con);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:27,代码来源:MUCPersistenceManager.java


示例10: run

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
public void run() {
    rooms = new ArrayList<RoomInfo>();
    // Get all services that have local occupants and include them in the reply
    for (MultiUserChatService mucService : XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatServices()) {
        // Get rooms that have local occupants and include them in the reply
        for (MUCRoom room : mucService.getChatRooms()) {
            LocalMUCRoom localRoom = (LocalMUCRoom) room;
            Collection<MUCRole> localOccupants = new ArrayList<MUCRole>();
            for (MUCRole occupant : room.getOccupants()) {
                if (occupant.isLocal()) {
                    localOccupants.add(occupant);
                }
            }
            if (!localOccupants.isEmpty()) {
                rooms.add(new RoomInfo(localRoom, localOccupants));
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:20,代码来源:GetNewMemberRoomsRequest.java


示例11: run

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
public void run(ConversationManager conversationManager) {
    if (Type.chatMessageReceived == type) {
        conversationManager.processMessage(sender, receiver, body, date);
    }
    else if (Type.roomDestroyed == type) {
        conversationManager.roomConversationEnded(roomJID, date);
    }
    else if (Type.occupantJoined == type) {
        conversationManager.joinedGroupConversation(roomJID, user, nickname, date);
    }
    else if (Type.occupantLeft == type) {
        conversationManager.leftGroupConversation(roomJID, user, date);
        // If there are no more occupants then consider the group conversarion over
        MUCRoom mucRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomJID.getNode());
        if (mucRoom != null &&  mucRoom.getOccupantsCount() == 0) {
            conversationManager.roomConversationEnded(roomJID, date);
        }
    }
    else if (Type.nicknameChanged == type) {
        conversationManager.leftGroupConversation(roomJID, user, date);
        conversationManager.joinedGroupConversation(roomJID, user, nickname, new Date(date.getTime() + 1));
    }
    else if (Type.roomMessageReceived == type) {
        conversationManager.processRoomMessage(roomJID, user, nickname, body, date);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:27,代码来源:ConversationEvent.java


示例12: Conversation

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Constructs a new group chat conversation that is taking place in a room.
 * 
 * @param conversationManager
 *            the ConversationManager.
 * @param room
 *            the JID of the room where the conversation is taking place.
 * @param external
 *            true if the conversation includes a user on another server.
 * @param startDate
 *            the starting date of the conversation.
 */
public Conversation(ConversationManager conversationManager, JID room, boolean external, Date startDate) {
	this.conversationManager = conversationManager;
	this.participants = new ConcurrentHashMap<String, UserParticipations>();
	// Add list of existing room occupants as participants of this conversation
	MUCRoom mucRoom = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(room).getChatRoom(room.getNode());
	if (mucRoom != null) {
		for (MUCRole role : mucRoom.getOccupants()) {
			UserParticipations userParticipations = new UserParticipations(true);
			userParticipations.addParticipation(new ConversationParticipation(startDate, role.getNickname()));
			participants.put(role.getUserAddress().toString(), userParticipations);
		}
	}
	this.room = room;
	this.external = external;
	this.startDate = startDate;
	this.lastActivity = startDate;
	// If archiving is enabled, insert the conversation into the database.
	if (conversationManager.isMetadataArchivingEnabled()) {
		try {
			insertIntoDb();
		} catch (Exception e) {
			Log.error(e.getMessage(), e);
		}
	}
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:38,代码来源:Conversation.java


示例13: ConversationLogEntry

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Creates a new ConversationLogEntry that registers that a given message was sent to a given
 * room on a given date.
 * 
 * @param date the date when the message was sent to the room.
 * @param room the room that received the message.
 * @param message the message to log as part of the conversation in the room.
 * @param sender the real XMPPAddress of the sender (e.g. [email protected]). 
 */
public ConversationLogEntry(Date date, MUCRoom room, Message message, JID sender) {
    this.date = date;
    this.subject = message.getSubject();
    this.body = message.getBody();
    this.stanza = message.toString();
    this.sender = sender;
    this.roomID = room.getID();
    this.nickname = message.getFrom().getResource();
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:19,代码来源:ConversationLogEntry.java


示例14: cleanupRooms

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
public void cleanupRooms(Date cleanUpDate) {
    for (MUCRoom room : getRooms()) {
        if (room.getEmptyDate() != null && room.getEmptyDate().before(cleanUpDate)) {
            removeRoom(room.getName());
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:LocalMUCRoomManager.java


示例15: sortByUserAmount

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Sorts the provided list in such a way that the MUC with the most users
 * will be the first one in the list.
 * 
 * @param mucs
 *            The unordered list that will be sorted.
 * @return The sorted list of MUC rooms.
 */
private static List<MUCRoom> sortByUserAmount(List<MUCRoom> mucs)
{
    Collections.sort(mucs, new Comparator<MUCRoom>()
    {
        @Override
        public int compare(MUCRoom o1, MUCRoom o2)
        {
            return o2.getOccupantsCount() - o1.getOccupantsCount();
        }
    });

    return mucs;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:IQMUCSearchHandler.java


示例16: canBeIncludedInResult

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Checks if the room may be included in search results. This is almost
 * identical to {@link MultiUserChatServiceImpl#canDiscoverRoom(org.jivesoftware.openfire.muc.MUCRoom, org.xmpp.packet.JID)},
 * but that method is private and cannot be re-used here.
 * 
 * @param room
 *            The room to check
 * @return ''true'' if the room may be included in search results, ''false''
 *         otherwise.
 */
private static boolean canBeIncludedInResult(MUCRoom room)
{
    // Check if locked rooms may be discovered
    final boolean discoverLocked = MUCPersistenceManager.getBooleanProperty(room.getMUCService().getServiceName(), "discover.locked", true);

    if (!discoverLocked && room.isLocked())
    {
        return false;
    }
    return room.isPublicRoom();
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:IQMUCSearchHandler.java


示例17: getChatRoom

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
@Override
public MUCRoom getChatRoom(String roomName) {
    boolean loaded = false;
    LocalMUCRoom room = localMUCRoomManager.getRoom(roomName);
    if (room == null) {
        // Check if the room exists in the databclase and was not present in memory
        synchronized (roomName.intern()) {
            room = localMUCRoomManager.getRoom(roomName);
            if (room == null) {
                room = new LocalMUCRoom(this, roomName, router);
                // If the room is persistent load the configuration values from the DB
                try {
                    // Try to load the room's configuration from the database (if the room is
                    // persistent but was added to the DB after the server was started up or the
                    // room may be an old room that was not present in memory)
                    MUCPersistenceManager.loadFromDB(room);
                    loaded = true;
                    localMUCRoomManager.addRoom(roomName,room);
                }
                catch (IllegalArgumentException e) {
                    // The room does not exist so do nothing
                    room = null;
                }
            }
        }
    }
    if (loaded) {
        // Notify other cluster nodes that a new room is available
        CacheFactory.doClusterTask(new RoomAvailableEvent(room));
    }
    return room;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:33,代码来源:MultiUserChatServiceImpl.java


示例18: removeChatRoom

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
private void removeChatRoom(String roomName, boolean notify) {
    MUCRoom room = localMUCRoomManager.removeRoom(roomName);
    if (room != null) {
        Log.info("removing chat room:" + roomName + "|" + room.getClass().getName());
        if (room instanceof LocalMUCRoom)
            GroupEventDispatcher.removeListener((LocalMUCRoom) room);
       totalChatTime += room.getChatLength();
        if (notify) {
            // Notify other cluster nodes that a room has been removed
            CacheFactory.doClusterTask(new RoomRemovedEvent((LocalMUCRoom)room));
        }
    } else {
        Log.info("No chatroom {} during removal.", roomName);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:MultiUserChatServiceImpl.java


示例19: getNumberRoomOccupants

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
/**
 * Retuns the total number of users that have joined in all rooms in the server.
 *
 * @return the number of existing rooms in the server.
 */
@Override
public int getNumberRoomOccupants() {
    int total = 0;
    for (MUCRoom room : localMUCRoomManager.getRooms()) {
        total = total + room.getOccupantsCount();
    }
    return total;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:14,代码来源:MultiUserChatServiceImpl.java


示例20: logConversation

import org.jivesoftware.openfire.muc.MUCRoom; //导入依赖的package包/类
@Override
public void logConversation(MUCRoom room, Message message, JID sender) {
    // Only log messages that have a subject or body. Otherwise ignore it.
    if (message.getSubject() != null || message.getBody() != null) {
        logQueue.add(new ConversationLogEntry(new Date(), room, message, sender));
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:MultiUserChatServiceImpl.java



注:本文中的org.jivesoftware.openfire.muc.MUCRoom类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GeohashUtils类代码示例发布时间:2022-05-22
下一篇:
Java AbstractMutableTreeTableNode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap