Search in sources :

Example 1 with ServiceInfo

use of org.jivesoftware.openfire.muc.cluster.ServiceInfo in project Openfire by igniterealtime.

the class MultiUserChatManager method joinedCluster.

// Cluster management tasks
@Override
public void joinedCluster() {
    if (!ClusterManager.isSeniorClusterMember()) {
        // Get transient rooms and persistent rooms with occupants from senior
        // cluster member and merge with local ones. If room configuration was
        // changed in both places then latest configuration will be kept
        @SuppressWarnings("unchecked") List<ServiceInfo> result = (List<ServiceInfo>) CacheFactory.doSynchronousClusterTask(new SeniorMemberServicesRequest(), ClusterManager.getSeniorClusterMember().toByteArray());
        if (result != null) {
            for (ServiceInfo serviceInfo : result) {
                MultiUserChatService service;
                service = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceInfo.getSubdomain());
                if (service == null) {
                    // This is a service we don't know about yet, create it locally and register it;
                    service = new MultiUserChatServiceImpl(serviceInfo.getSubdomain(), serviceInfo.getDescription(), serviceInfo.isHidden());
                    XMPPServer.getInstance().getMultiUserChatManager().registerMultiUserChatService(service);
                }
                MultiUserChatServiceImpl serviceImpl = (MultiUserChatServiceImpl) service;
                for (RoomInfo roomInfo : serviceInfo.getRooms()) {
                    LocalMUCRoom remoteRoom = roomInfo.getRoom();
                    LocalMUCRoom localRoom = serviceImpl.getLocalChatRoom(remoteRoom.getName());
                    if (localRoom == null) {
                        // Create local room with remote information
                        localRoom = remoteRoom;
                        serviceImpl.chatRoomAdded(localRoom);
                    } else {
                        // Update local room with remote information
                        localRoom.updateConfiguration(remoteRoom);
                    }
                    // TODO Handle conflict of nicknames
                    for (OccupantAddedEvent event : roomInfo.getOccupants()) {
                        event.setSendPresence(true);
                        event.run();
                    }
                }
            }
        }
    }
}
Also used : ServiceInfo(org.jivesoftware.openfire.muc.cluster.ServiceInfo) SeniorMemberServicesRequest(org.jivesoftware.openfire.muc.cluster.SeniorMemberServicesRequest) 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)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 OccupantAddedEvent (org.jivesoftware.openfire.muc.cluster.OccupantAddedEvent)1 RoomInfo (org.jivesoftware.openfire.muc.cluster.RoomInfo)1 SeniorMemberServicesRequest (org.jivesoftware.openfire.muc.cluster.SeniorMemberServicesRequest)1 ServiceInfo (org.jivesoftware.openfire.muc.cluster.ServiceInfo)1 LocalMUCRoom (org.jivesoftware.openfire.muc.spi.LocalMUCRoom)1 MultiUserChatServiceImpl (org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl)1