Commit f1501319 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

MUC events are only triggered in the cluster node that created the event....

MUC events are only triggered in the cluster node that created the event. JM-1300. Reviewed by Daniel.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10067 b35dd754-fafc-0310-a699-88a17e54d16e
parent f570beb2
...@@ -639,8 +639,10 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -639,8 +639,10 @@ public class LocalMUCRoom implements MUCRoom {
// Update the date when the last occupant left the room // Update the date when the last occupant left the room
setEmptyDate(null); setEmptyDate(null);
if (event.isOriginator()) {
// Fire event that occupant joined the room // Fire event that occupant joined the room
server.fireOccupantJoined(getRole().getRoleAddress(), event.getUserAddress(), joinRole.getNickname()); server.fireOccupantJoined(getRole().getRoleAddress(), event.getUserAddress(), joinRole.getNickname());
}
// Check if we need to send presences of the new occupant to occupants hosted by this JVM // Check if we need to send presences of the new occupant to occupants hosted by this JVM
if (event.isSendPresence()) { if (event.isSendPresence()) {
for (MUCRole occupant : occupants.values()) { for (MUCRole occupant : occupants.values()) {
...@@ -695,7 +697,7 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -695,7 +697,7 @@ public class LocalMUCRoom implements MUCRoom {
lock.writeLock().lock(); lock.writeLock().lock();
try { try {
// Removes the role from the room // Removes the role from the room
removeOccupantRole(leaveRole); removeOccupantRole(leaveRole, event.isOriginator());
// TODO Implement this: If the room owner becomes unavailable for any reason before // TODO Implement this: If the room owner becomes unavailable for any reason before
// submitting the form (e.g., a lost connection), the service will receive a presence // submitting the form (e.g., a lost connection), the service will receive a presence
...@@ -710,10 +712,10 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -710,10 +712,10 @@ public class LocalMUCRoom implements MUCRoom {
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();
if (event.isOriginator()) { if (event.isOriginator()) {
server.removeChatRoom(name); server.removeChatRoom(name);
}
// Fire event that the room has been destroyed // Fire event that the room has been destroyed
server.fireRoomDestroyed(getRole().getRoleAddress()); server.fireRoomDestroyed(getRole().getRoleAddress());
} }
}
if (occupants.isEmpty()) { if (occupants.isEmpty()) {
// Update the date when the last occupant left the room // Update the date when the last occupant left the room
setEmptyDate(new Date()); setEmptyDate(new Date());
...@@ -729,8 +731,9 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -729,8 +731,9 @@ public class LocalMUCRoom implements MUCRoom {
* also be removed from the user's roles. * also be removed from the user's roles.
* *
* @param leaveRole the role to remove. * @param leaveRole the role to remove.
* @param originator true if this JVM is the one that originated the event.
*/ */
private void removeOccupantRole(MUCRole leaveRole) { private void removeOccupantRole(MUCRole leaveRole, boolean originator) {
occupants.remove(leaveRole.getNickname().toLowerCase()); occupants.remove(leaveRole.getNickname().toLowerCase());
JID userAddress = leaveRole.getUserAddress(); JID userAddress = leaveRole.getUserAddress();
...@@ -745,9 +748,11 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -745,9 +748,11 @@ public class LocalMUCRoom implements MUCRoom {
} }
} }
occupantsByFullJID.remove(userAddress); occupantsByFullJID.remove(userAddress);
if (originator) {
// Fire event that occupant left the room // Fire event that occupant left the room
server.fireOccupantLeft(getRole().getRoleAddress(), userAddress); server.fireOccupantLeft(getRole().getRoleAddress(), userAddress);
} }
}
public void destroyRoom(DestroyRoomRequest destroyRequest) { public void destroyRoom(DestroyRoomRequest destroyRequest) {
String alternateJID = destroyRequest.getAlternateJID(); String alternateJID = destroyRequest.getAlternateJID();
...@@ -770,7 +775,7 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -770,7 +775,7 @@ public class LocalMUCRoom implements MUCRoom {
else { else {
hasRemoteOccupants = true; hasRemoteOccupants = true;
} }
removeOccupantRole(leaveRole); removeOccupantRole(leaveRole, destroyRequest.isOriginator());
} }
} }
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();
...@@ -820,10 +825,10 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -820,10 +825,10 @@ public class LocalMUCRoom implements MUCRoom {
if (destroyRequest.isOriginator()) { if (destroyRequest.isOriginator()) {
// Remove the room from the DB if the room was persistent // Remove the room from the DB if the room was persistent
MUCPersistenceManager.deleteFromDB(this); MUCPersistenceManager.deleteFromDB(this);
}
// Fire event that the room has been destroyed // Fire event that the room has been destroyed
server.fireRoomDestroyed(getRole().getRoleAddress()); server.fireRoomDestroyed(getRole().getRoleAddress());
} }
}
public void destroyRoom(String alternateJID, String reason) { public void destroyRoom(String alternateJID, String reason) {
DestroyRoomRequest destroyRequest = new DestroyRoomRequest(this, alternateJID, reason); DestroyRoomRequest destroyRequest = new DestroyRoomRequest(this, alternateJID, reason);
...@@ -1547,9 +1552,11 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -1547,9 +1552,11 @@ public class LocalMUCRoom implements MUCRoom {
// Update the role with the new info // Update the role with the new info
occupantRole.setPresence(changeNickname.getPresence()); occupantRole.setPresence(changeNickname.getPresence());
occupantRole.changeNickname(changeNickname.getNewNick()); occupantRole.changeNickname(changeNickname.getNewNick());
if (changeNickname.isOriginator()) {
// Fire event that user changed his nickname // Fire event that user changed his nickname
server.fireNicknameChanged(getRole().getRoleAddress(), occupantRole.getUserAddress(), server.fireNicknameChanged(getRole().getRoleAddress(), occupantRole.getUserAddress(),
changeNickname.getOldNick(), changeNickname.getNewNick()); changeNickname.getOldNick(), changeNickname.getNewNick());
}
// Associate the existing MUCRole with the new nickname // Associate the existing MUCRole with the new nickname
occupants.put(changeNickname.getNewNick().toLowerCase(), occupantRole); occupants.put(changeNickname.getNewNick().toLowerCase(), occupantRole);
// Remove the old nickname // Remove the old nickname
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment