diff --git a/src/java/com/threerings/crowd/chat/client/ChatDirector.java b/src/java/com/threerings/crowd/chat/client/ChatDirector.java
index ef060cd0d..085fc18b4 100644
--- a/src/java/com/threerings/crowd/chat/client/ChatDirector.java
+++ b/src/java/com/threerings/crowd/chat/client/ChatDirector.java
@@ -1,5 +1,5 @@
//
-// $Id: ChatDirector.java,v 1.49 2003/09/16 21:26:15 ray Exp $
+// $Id: ChatDirector.java,v 1.50 2003/09/18 17:53:48 mdb Exp $
package com.threerings.crowd.chat.client;
@@ -363,17 +363,24 @@ public class ChatDirector extends BasicDirector
// create a listener that will report success or failure
ChatService.TellListener listener = new ChatService.TellListener() {
- public void tellSucceeded () {
+ public void tellSucceeded (long idletime, String awayMessage) {
success(xlate(_bundle, MessageBundle.tcompose(
"m.told_format", target, message)));
- }
- public void tellSucceededIdle (long idletime) {
- String msg = MessageBundle.compose(
- "m.told_idle_format", MessageBundle.taint(target),
- MessageBundle.taint(message),
- TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE));
- success(xlate(_bundle, msg));
+ // if they have an away message, report that
+ if (awayMessage != null) {
+ String msg = MessageBundle.tcompose(
+ "m.recipient_afk", target, awayMessage);
+ displayFeedback(_bundle, msg);
+ }
+
+ // if they are idle, report that
+ if (idletime > 0L) {
+ String msg = MessageBundle.compose(
+ "m.recipient_idle", MessageBundle.taint(target),
+ TimeUtil.getTimeOrderString(idletime, TimeUtil.MINUTE));
+ displayFeedback(_bundle, msg);
+ }
}
protected void success (String feedback) {
@@ -397,6 +404,17 @@ public class ChatDirector extends BasicDirector
_cservice.tell(_ctx.getClient(), target, message, listener);
}
+ /**
+ * Configures a message that will be automatically reported to anyone
+ * that sends a tell message to this client to indicate that we are
+ * busy or away from the keyboard.
+ */
+ public void setAwayMessage (String message)
+ {
+ // pass the buck right on along
+ _cservice.away(_ctx.getClient(), message);
+ }
+
/**
* Adds an additional object via which chat messages may arrive. The
* chat director assumes the caller will be managing the subscription
diff --git a/src/java/com/threerings/crowd/chat/client/ChatService.java b/src/java/com/threerings/crowd/chat/client/ChatService.java
index c88763e59..2938240b3 100644
--- a/src/java/com/threerings/crowd/chat/client/ChatService.java
+++ b/src/java/com/threerings/crowd/chat/client/ChatService.java
@@ -1,5 +1,5 @@
//
-// $Id: ChatService.java,v 1.11 2003/06/03 21:41:33 ray Exp $
+// $Id: ChatService.java,v 1.12 2003/09/18 17:53:48 mdb Exp $
package com.threerings.crowd.chat.client;
@@ -20,17 +20,15 @@ public interface ChatService extends InvocationService
*/
public static interface TellListener extends InvocationListener
{
- /**
- * Communicates the response to a {@link #tell} request.
- */
- public void tellSucceeded ();
-
/**
* Communicates the response to a {@link #tell} request.
*
- * @param idletime, the number of ms the tellee has been idle.
+ * @param idletime the number of ms the tellee has been idle or 0L
+ * if they are not idle.
+ * @param awayMessage the away message configured by the told
+ * player or null if they have no away message.
*/
- public void tellSucceededIdle (long idletime);
+ public void tellSucceeded (long idleTime, String awayMessage);
}
/**
@@ -55,4 +53,10 @@ public interface ChatService extends InvocationService
*/
public void broadcast (Client client, String message,
InvocationListener listener);
+
+ /**
+ * Sets this client's away message. If the message is null or the
+ * empty string, the away message will be cleared.
+ */
+ public void away (Client client, String message);
}
diff --git a/src/java/com/threerings/crowd/chat/data/ChatMarshaller.java b/src/java/com/threerings/crowd/chat/data/ChatMarshaller.java
index bb9fc872b..8857e6ee3 100644
--- a/src/java/com/threerings/crowd/chat/data/ChatMarshaller.java
+++ b/src/java/com/threerings/crowd/chat/data/ChatMarshaller.java
@@ -1,5 +1,5 @@
//
-// $Id: ChatMarshaller.java,v 1.5 2003/06/03 21:41:33 ray Exp $
+// $Id: ChatMarshaller.java,v 1.6 2003/09/18 17:53:48 mdb Exp $
package com.threerings.crowd.chat.data;
@@ -29,23 +29,11 @@ public class ChatMarshaller extends InvocationMarshaller
public static final int TELL_SUCCEEDED = 1;
// documentation inherited from interface
- public void tellSucceeded ()
+ public void tellSucceeded (long arg1, String arg2)
{
omgr.postEvent(new InvocationResponseEvent(
callerOid, requestId, TELL_SUCCEEDED,
- new Object[] { }));
- }
-
- /** The method id used to dispatch {@link #tellSucceededIdle}
- * responses. */
- public static final int TELL_SUCCEEDED_IDLE = 2;
-
- // documentation inherited from interface
- public void tellSucceededIdle (long arg1)
- {
- omgr.postEvent(new InvocationResponseEvent(
- callerOid, requestId, TELL_SUCCEEDED_IDLE,
- new Object[] { new Long(arg1) }));
+ new Object[] { new Long(arg1), arg2 }));
}
// documentation inherited
@@ -54,12 +42,7 @@ public class ChatMarshaller extends InvocationMarshaller
switch (methodId) {
case TELL_SUCCEEDED:
((TellListener)listener).tellSucceeded(
- );
- return;
-
- case TELL_SUCCEEDED_IDLE:
- ((TellListener)listener).tellSucceededIdle(
- ((Long)args[0]).longValue());
+ ((Long)args[0]).longValue(), (String)args[1]);
return;
default:
@@ -94,4 +77,15 @@ public class ChatMarshaller extends InvocationMarshaller
});
}
+ /** The method id used to dispatch {@link #away} requests. */
+ public static final int AWAY = 3;
+
+ // documentation inherited from interface
+ public void away (Client arg1, String arg2)
+ {
+ sendRequest(arg1, AWAY, new Object[] {
+ arg2
+ });
+ }
+
}
diff --git a/src/java/com/threerings/crowd/chat/server/ChatDispatcher.java b/src/java/com/threerings/crowd/chat/server/ChatDispatcher.java
index a73d6111a..68a74f5ee 100644
--- a/src/java/com/threerings/crowd/chat/server/ChatDispatcher.java
+++ b/src/java/com/threerings/crowd/chat/server/ChatDispatcher.java
@@ -1,5 +1,5 @@
//
-// $Id: ChatDispatcher.java,v 1.5 2003/06/03 21:41:33 ray Exp $
+// $Id: ChatDispatcher.java,v 1.6 2003/09/18 17:53:48 mdb Exp $
package com.threerings.crowd.chat.server;
@@ -53,6 +53,13 @@ public class ChatDispatcher extends InvocationDispatcher
);
return;
+ case ChatMarshaller.AWAY:
+ ((ChatProvider)provider).away(
+ source,
+ (String)args[0]
+ );
+ return;
+
default:
super.dispatchRequest(source, methodId, args);
}
diff --git a/src/java/com/threerings/crowd/chat/server/ChatProvider.java b/src/java/com/threerings/crowd/chat/server/ChatProvider.java
index 1a789a36b..0408624b8 100644
--- a/src/java/com/threerings/crowd/chat/server/ChatProvider.java
+++ b/src/java/com/threerings/crowd/chat/server/ChatProvider.java
@@ -1,10 +1,11 @@
//
-// $Id: ChatProvider.java,v 1.24 2003/07/18 01:58:38 eric Exp $
+// $Id: ChatProvider.java,v 1.25 2003/09/18 17:53:48 mdb Exp $
package com.threerings.crowd.chat.server;
import java.util.Iterator;
+import com.samskivert.util.StringUtil;
import com.threerings.util.MessageBundle;
import com.threerings.util.TimeUtil;
@@ -111,14 +112,15 @@ public class ChatProvider
sendTellMessage(tobj, source.username, null, message);
// let the teller know it went ok
+ long idle = 0L;
if (tobj.status == OccupantInfo.IDLE) {
- listener.tellSucceededIdle(
- System.currentTimeMillis() - tobj.statusTime);
-
- } else {
- // normal success
- listener.tellSucceeded();
+ idle = System.currentTimeMillis() - tobj.statusTime;
}
+ String awayMessage = null;
+ if (!StringUtil.blank(tobj.awayMessage)) {
+ awayMessage = tobj.awayMessage;
+ }
+ listener.tellSucceeded(idle, awayMessage);
// do the autoresponse if needed
if (_autoRespond != null) {
@@ -150,6 +152,17 @@ public class ChatProvider
}
}
+ /**
+ * Processes a {@link ClientService#away} request.
+ */
+ public void away (ClientObject caller, String message)
+ {
+ BodyObject body = (BodyObject)caller;
+ // we modify this field via an invocation service request because
+ // a body object is not modifiable by the client
+ body.setAwayMessage(message);
+ }
+
/**
* Delivers a tell notification to the specified target player,
* originating with the specified speaker.
diff --git a/src/java/com/threerings/crowd/data/BodyObject.dobj b/src/java/com/threerings/crowd/data/BodyObject.dobj
index 14f137a5f..a586364ea 100644
--- a/src/java/com/threerings/crowd/data/BodyObject.dobj
+++ b/src/java/com/threerings/crowd/data/BodyObject.dobj
@@ -1,5 +1,5 @@
//
-// $Id: BodyObject.dobj,v 1.12 2003/06/14 00:55:40 mdb Exp $
+// $Id: BodyObject.dobj,v 1.13 2003/09/18 17:53:48 mdb Exp $
package com.threerings.crowd.data;
@@ -35,6 +35,12 @@ public class BodyObject extends ClientObject
*/
public transient long statusTime;
+ /**
+ * If non-null, this contains a message to be auto-replied whenever
+ * another user delivers a tell message to this user.
+ */
+ public String awayMessage;
+
// documentation inherited
public void applyToListeners (ListenerOp op)
{
diff --git a/src/java/com/threerings/crowd/data/BodyObject.java b/src/java/com/threerings/crowd/data/BodyObject.java
index 8baf9c3f2..6debc80ac 100644
--- a/src/java/com/threerings/crowd/data/BodyObject.java
+++ b/src/java/com/threerings/crowd/data/BodyObject.java
@@ -1,5 +1,5 @@
//
-// $Id: BodyObject.java,v 1.7 2003/06/14 00:55:40 mdb Exp $
+// $Id: BodyObject.java,v 1.8 2003/09/18 17:53:48 mdb Exp $
package com.threerings.crowd.data;
@@ -22,6 +22,9 @@ public class BodyObject extends ClientObject
/** The field name of the status field. */
public static final String STATUS = "status";
+ /** The field name of the awayMessage field. */
+ public static final String AWAY_MESSAGE = "awayMessage";
+
/**
* The username associated with this body object.
*/
@@ -44,6 +47,12 @@ public class BodyObject extends ClientObject
*/
public transient long statusTime;
+ /**
+ * If non-null, this contains a message to be auto-replied whenever
+ * another user delivers a tell message to this user.
+ */
+ public String awayMessage;
+
// documentation inherited
public void applyToListeners (ListenerOp op)
{
@@ -102,4 +111,18 @@ public class BodyObject extends ClientObject
requestAttributeChange(STATUS, new Byte(status));
this.status = status;
}
+
+ /**
+ * Requests that the awayMessage field be set to the specified
+ * value. The local value will be updated immediately and an event
+ * will be propagated through the system to notify all listeners that
+ * the attribute did change. Proxied copies of this object (on
+ * clients) will apply the value change when they received the
+ * attribute changed notification.
+ */
+ public void setAwayMessage (String awayMessage)
+ {
+ requestAttributeChange(AWAY_MESSAGE, awayMessage);
+ this.awayMessage = awayMessage;
+ }
}