use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl 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.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.
the class MultiUserChatManager method removeMultiUserChatService.
/**
* Deletes a configured MultiUserChatService by ID, and shuts it down.
*
* @param serviceID The ID opf the service to be deleted.
* @throws NotFoundException if the service was not found.
*/
public void removeMultiUserChatService(Long serviceID) throws NotFoundException {
MultiUserChatServiceImpl muc = (MultiUserChatServiceImpl) getMultiUserChatService(serviceID);
if (muc == null) {
Log.error("MultiUserChatManager: Unable to find service to remove for service ID " + serviceID);
throw new NotFoundException();
}
unregisterMultiUserChatService(muc.getServiceName());
deleteService(serviceID);
}
use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.
the class MultiUserChatManager method updateMultiUserChatService.
/**
* Updates the configuration of a MUC service. This is more involved than it may seem. If the
* subdomain is changed, we need to shut down the old service and start up the new one, registering
* the new subdomain and cleaning up the old one. Properties are tied to the ID, which will not change.
*
* @param serviceID The ID of the service to be updated.
* @param subdomain New subdomain to assign to the service.
* @param description New description to assign to the service.
* @throws NotFoundException if service was not found.
*/
public void updateMultiUserChatService(Long serviceID, String subdomain, String description) throws NotFoundException {
MultiUserChatServiceImpl muc = (MultiUserChatServiceImpl) getMultiUserChatService(serviceID);
if (muc == null)
throw new NotFoundException();
// A NotFoundException is thrown if the specified service was not found.
String oldsubdomain = muc.getServiceName();
if (!mucServices.containsKey(oldsubdomain)) {
// This should never occur, but just in case...
throw new NotFoundException();
}
if (oldsubdomain.equals(subdomain)) {
// Alright, all we're changing is the description. This is easy.
updateService(serviceID, subdomain, description);
// Update the existing service's description.
muc.setDescription(description);
} else {
// Changing the subdomain, here's where it gets complex.
// Unregister existing muc service
unregisterMultiUserChatService(subdomain);
// Update the information stored about the MUC service
updateService(serviceID, subdomain, description);
// Create new MUC service with new settings
muc = new MultiUserChatServiceImpl(subdomain, description, muc.isHidden());
// Register to new service
registerMultiUserChatService(muc);
}
}
use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.
the class UpdateHistoryStrategy method run.
@Override
public void run() {
MultiUserChatServiceImpl mucServer = (MultiUserChatServiceImpl) XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(serviceName);
if (mucServer == null)
throw new IllegalArgumentException("MUC service not found for subdomain: " + serviceName);
HistoryStrategy strategy = mucServer.getHistoryStrategy();
strategy.setType(HistoryStrategy.Type.values()[type]);
strategy.setMaxNumber(maxNumber);
}
use of org.jivesoftware.openfire.muc.spi.MultiUserChatServiceImpl in project Openfire by igniterealtime.
the class SyncLocalOccupantsAndSendJoinPresenceTask method run.
@Override
public void run() {
Log.debug("Going to execute sync occupants task for {} occupants from node {}", occupants.size(), originator);
final MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService(subdomain);
((MultiUserChatServiceImpl) multiUserChatService).process(this);
Log.trace("Finished executing sync occupants task for occupants {} from node {}", occupants.size(), originator);
}
Aggregations