01: /**
02: * $RCSfile: $
03: * $Revision: $
04: * $Date: $
05: *
06: * Copyright (C) 2007 Jive Software. All rights reserved.
07: *
08: * This software is published under the terms of the GNU Public License (GPL),
09: * a copy of which is included in this distribution.
10: */package org.jivesoftware.openfire.muc.cluster;
11:
12: import org.dom4j.Element;
13: import org.dom4j.tree.DefaultElement;
14: import org.jivesoftware.openfire.muc.spi.LocalMUCRoom;
15: import org.jivesoftware.util.cache.ExternalizableUtil;
16: import org.xmpp.packet.Presence;
17:
18: import java.io.IOException;
19: import java.io.ObjectInput;
20: import java.io.ObjectOutput;
21:
22: /**
23: * Task that updates the presence of an occupant in a room. Each time an occupant
24: * changes his presence in the room the other cluster nodes will need to get the
25: * presence updated too for the occupant.
26: *
27: * @author Gaston Dombiak
28: */
29: public class UpdatePresence extends MUCRoomTask {
30: private Presence presence;
31: private String nickname;
32:
33: public UpdatePresence() {
34: }
35:
36: public UpdatePresence(LocalMUCRoom room, Presence presence,
37: String nickname) {
38: super (room);
39: this .presence = presence;
40: this .nickname = nickname;
41: }
42:
43: public Presence getPresence() {
44: return presence;
45: }
46:
47: public String getNickname() {
48: return nickname;
49: }
50:
51: public Object getResult() {
52: return null;
53: }
54:
55: public void run() {
56: getRoom().presenceUpdated(this );
57: }
58:
59: public void writeExternal(ObjectOutput out) throws IOException {
60: super .writeExternal(out);
61: ExternalizableUtil.getInstance().writeSerializable(out,
62: (DefaultElement) presence.getElement());
63: ExternalizableUtil.getInstance().writeSafeUTF(out, nickname);
64: }
65:
66: public void readExternal(ObjectInput in) throws IOException,
67: ClassNotFoundException {
68: super .readExternal(in);
69: Element packetElement = (Element) ExternalizableUtil
70: .getInstance().readSerializable(in);
71: presence = new Presence(packetElement, true);
72: nickname = ExternalizableUtil.getInstance().readSafeUTF(in);
73: }
74: }
|