Refactored /tell idle auto-response; added support for configuring an

away/busy auto-response message.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2797 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-09-18 17:53:48 +00:00
parent e876090b93
commit 6add22f5d7
7 changed files with 113 additions and 48 deletions
@@ -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
@@ -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);
}