use of org.jivesoftware.openfire.muc.cluster.RoomInfo 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();
}
}
}
}
}
}
use of org.jivesoftware.openfire.muc.cluster.RoomInfo 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();
}
}
}
}
Aggregations