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

Update other cluster nodes when a user becomes a member when invited to a room. JM-1265

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9870 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8993edb0
/**
* $RCSfile: $
* $Revision: $
* $Date: $
*
* Copyright (C) 2008 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.openfire.muc.cluster;
import org.jivesoftware.openfire.muc.spi.LocalMUCRoom;
import org.jivesoftware.util.cache.ExternalizableUtil;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
/**
* Task that adds a new member to the room in the other cluster nodes.
*
* @author Gaston Dombiak
*/
public class AddMember extends MUCRoomTask {
private String bareJID;
private String nickname;
public AddMember() {
super();
}
public AddMember(LocalMUCRoom room, String bareJID, String nickname) {
super(room);
this.bareJID = bareJID;
this.nickname = nickname;
}
public String getBareJID() {
return bareJID;
}
public String getNickname() {
return nickname;
}
public Object getResult() {
return null;
}
public void run() {
getRoom().memberAdded(this);
}
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
ExternalizableUtil.getInstance().writeSafeUTF(out, bareJID);
ExternalizableUtil.getInstance().writeSafeUTF(out, nickname);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
bareJID = ExternalizableUtil.getInstance().readSafeUTF(in);
nickname = ExternalizableUtil.getInstance().readSafeUTF(in);
}
}
...@@ -1292,6 +1292,8 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -1292,6 +1292,8 @@ public class LocalMUCRoom implements MUCRoom {
nickname, nickname,
MUCRole.Affiliation.member, MUCRole.Affiliation.member,
oldAffiliation); oldAffiliation);
// Update other cluster nodes with new member
CacheFactory.doClusterTask(new AddMember(this, bareJID, (nickname == null ? "" : nickname)));
// Update the presence with the new affiliation and inform all occupants // Update the presence with the new affiliation and inform all occupants
try { try {
return changeOccupantAffiliation(bareJID, MUCRole.Affiliation.member, return changeOccupantAffiliation(bareJID, MUCRole.Affiliation.member,
...@@ -1520,6 +1522,11 @@ public class LocalMUCRoom implements MUCRoom { ...@@ -1520,6 +1522,11 @@ public class LocalMUCRoom implements MUCRoom {
return null; return null;
} }
public void memberAdded(AddMember addMember) {
// Associate the reserved nickname with the bareJID
members.put(addMember.getBareJID(), addMember.getNickname());
}
public void nicknameChanged(MUCRole occupantRole, Presence newPresence, String oldNick, String newNick) { public void nicknameChanged(MUCRole occupantRole, Presence newPresence, String oldNick, String newNick) {
// Ask other cluster nodes to update the nickname of the occupant // Ask other cluster nodes to update the nickname of the occupant
ChangeNickname request = new ChangeNickname(this, oldNick, newNick, newPresence.createCopy()); ChangeNickname request = new ChangeNickname(this, oldNick, newNick, newPresence.createCopy());
......
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