Search in sources :

Example 1 with GetNewMemberRoomsRequest

use of org.jivesoftware.openfire.muc.cluster.GetNewMemberRoomsRequest 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)

Aggregations

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