Search in sources :

Example 6 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class MultiUserChatManager method createMultiUserChatService.

/**
     * Creates a new MUC service and registers it with the manager, and starts up the service.
     *
     * @param subdomain Subdomain of the MUC service.
     * @param description Description of the MUC service (can be null for default description)
     * @param isHidden True if the service is hidden from view in services lists.
     * @return MultiUserChatService implementation that was just created.
     * @throws AlreadyExistsException if the service already exists.
     */
public MultiUserChatServiceImpl createMultiUserChatService(String subdomain, String description, Boolean isHidden) throws AlreadyExistsException {
    if (getMultiUserChatServiceID(subdomain) != null)
        throw new AlreadyExistsException();
    MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description, isHidden);
    insertService(subdomain, description, isHidden);
    registerMultiUserChatService(muc);
    return muc;
}
Also used : AlreadyExistsException(org.jivesoftware.util.AlreadyExistsException) MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl)

Example 7 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class MultiUserChatManager method joinedCluster.

@Override
@SuppressWarnings("unchecked")
public void joinedCluster(byte[] nodeID) {
    Object result = CacheFactory.doSynchronousClusterTask(new GetNewMemberRoomsRequest(), nodeID);
    if (result instanceof List<?>) {
        List<RoomInfo> rooms = (List<RoomInfo>) result;
        for (RoomInfo roomInfo : rooms) {
            LocalMUCRoom remoteRoom = roomInfo.getRoom();
            MultiUserChatServiceImpl service = (MultiUserChatServiceImpl) remoteRoom.getMUCService();
            LocalMUCRoom localRoom = service.getLocalChatRoom(remoteRoom.getName());
            if (localRoom == null) {
                // Create local room with remote information
                localRoom = remoteRoom;
                service.chatRoomAdded(localRoom);
            }
            // Add remote occupants to local room
            for (OccupantAddedEvent event : roomInfo.getOccupants()) {
                event.setSendPresence(true);
                event.run();
            }
        }
    }
}
Also used : LocalMUCRoom(org.jivesoftware.openfire.muc.spi.LocalMUCRoom) MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) RoomInfo(org.jivesoftware.openfire.muc.cluster.RoomInfo) ArrayList(java.util.ArrayList) List(java.util.List) OccupantAddedEvent(org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent) GetNewMemberRoomsRequest(org.jivesoftware.openfire.muc.cluster.GetNewMemberRoomsRequest)

Example 8 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class MultiUserChatManager method loadServices.

/**
     * Loads the list of configured services stored in the database.
     */
private void loadServices() {
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(LOAD_SERVICES);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            String subdomain = rs.getString(1);
            String description = rs.getString(2);
            Boolean isHidden = Boolean.valueOf(rs.getString(3));
            MultiUserChatServiceImpl muc = new MultiUserChatServiceImpl(subdomain, description, isHidden);
            mucServices.put(subdomain, muc);
        }
    } catch (Exception e) {
        Log.error(e.getMessage(), e);
    } finally {
        DbConnectionManager.closeConnection(rs, pstmt, con);
    }
}
Also used : Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) PreparedStatement(java.sql.PreparedStatement) ComponentException(org.xmpp.component.ComponentException) SQLException(java.sql.SQLException) NotFoundException(org.jivesoftware.util.NotFoundException) AlreadyExistsException(org.jivesoftware.util.AlreadyExistsException)

Example 9 with MultiUserChatServiceImpl

use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.

the class ServiceAddedEvent method run.

@Override
public void run() {
    // should really never occur.
    if (!XMPPServer.getInstance().getMultiUserChatManager().isServiceRegistered(subdomain)) {
        MultiUserChatService service = new MultiUserChatServiceImpl(subdomain, description, isHidden);
        XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(service);
    }
}
Also used : MultiUserChatServiceImpl(org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl) MultiUserChatService(org.jivesoftware.openfire.muc.MultiUserChatService)

Aggregations

MultiUserChatServiceImpl (org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl)9 NotFoundException (org.jivesoftware.util.NotFoundException)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MultiUserChatService (org.jivesoftware.openfire.muc.MultiUserChatService)2 OccupantAddedEvent (org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent)2 RoomInfo (org.jivesoftware.openfire.muc.cluster.RoomInfo)2 LocalMUCRoom (org.jivesoftware.openfire.muc.spi.LocalMUCRoom)2 AlreadyExistsException (org.jivesoftware.util.AlreadyExistsException)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 HistoryStrategy (org.jivesoftware.openfire.muc.HistoryStrategy)1 GetNewMemberRoomsRequest (org.jivesoftware.openfire.muc.cluster.GetNewMemberRoomsRequest)1 SeniorMemberServicesRequest (org.jivesoftware.openfire.muc.cluster.SeniorMemberServicesRequest)1 ServiceInfo (org.jivesoftware.openfire.muc.cluster.ServiceInfo)1 ComponentException (org.xmpp.component.ComponentException)1