Commit cc58739b 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/branches/openfire_3_5_0@10066 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4d51927b
...@@ -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);
// Fire event that occupant joined the room if (event.isOriginator()) {
server.fireOccupantJoined(getRole().getRoleAddress(), event.getUserAddress(), joinRole.getNickname()); // Fire event that occupant joined the room
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,9 +712,9 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -710,9 +712,9 @@ 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
server.fireRoomDestroyed(getRole().getRoleAddress());
} }
// Fire event that the room has been destroyed
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
...@@ -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,8 +748,10 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -745,8 +748,10 @@ public class LocalMUCRoom implements MUCRoom {
} }
} }
occupantsByFullJID.remove(userAddress); occupantsByFullJID.remove(userAddress);
// Fire event that occupant left the room if (originator) {
server.fireOccupantLeft(getRole().getRoleAddress(), userAddress); // Fire event that occupant left the room
server.fireOccupantLeft(getRole().getRoleAddress(), userAddress);
}
} }
public void destroyRoom(DestroyRoomRequest destroyRequest) { public void destroyRoom(DestroyRoomRequest destroyRequest) {
...@@ -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,9 +825,9 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -820,9 +825,9 @@ 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
server.fireRoomDestroyed(getRole().getRoleAddress());
} }
// Fire event that the room has been destroyed
server.fireRoomDestroyed(getRole().getRoleAddress());
} }
public void destroyRoom(String alternateJID, String reason) { public void destroyRoom(String alternateJID, String 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());
// Fire event that user changed his nickname if (changeNickname.isOriginator()) {
server.fireNicknameChanged(getRole().getRoleAddress(), occupantRole.getUserAddress(), // Fire event that user changed his nickname
changeNickname.getOldNick(), changeNickname.getNewNick()); server.fireNicknameChanged(getRole().getRoleAddress(), occupantRole.getUserAddress(),
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
...@@ -2214,4 +2221,4 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -2214,4 +2221,4 @@ public class LocalMUCRoom implements MUCRoom {
// name is unique for each one particular MUC service. // name is unique for each one particular MUC service.
return name; return name;
} }
} }
\ No newline at end of file
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