Added support for think and emote.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1599 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2002-07-22 22:26:26 +00:00
parent af8b7bf237
commit 5c5038690b
9 changed files with 82 additions and 25 deletions
@@ -1,5 +1,5 @@
// //
// $Id: ChatDirector.java,v 1.25 2002/07/17 20:53:31 shaper Exp $ // $Id: ChatDirector.java,v 1.26 2002/07/22 22:26:26 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat;
@@ -351,21 +351,24 @@ public class ChatDirector
} }
String bundle = null; String bundle = null;
String message = null; String message, mode;
// determine whether this speak message originated from another // determine whether this speak message originated from another
// client or from a server entity // client or from a server entity
if (args.length == 2) { if (args.length == 3) {
message = (String)args[1]; message = (String)args[1];
mode = (String) args[2];
} else { } else {
bundle = (String)args[1]; bundle = (String)args[1];
message = (String)args[2]; message = (String)args[2];
mode = (String) args[3];
} }
// pass this on to our chat displays // pass this on to our chat displays
for (int i = 0; i < _displays.size(); i++) { for (int i = 0; i < _displays.size(); i++) {
ChatDisplay display = (ChatDisplay)_displays.get(i); ChatDisplay display = (ChatDisplay)_displays.get(i);
display.displaySpeakMessage(type, speaker, bundle, message); display.displaySpeakMessage(type, speaker, bundle, message, mode);
} }
} }
@@ -1,5 +1,5 @@
// //
// $Id: ChatDisplay.java,v 1.10 2002/07/17 20:53:31 shaper Exp $ // $Id: ChatDisplay.java,v 1.11 2002/07/22 22:26:26 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat;
@@ -27,9 +27,13 @@ public interface ChatDisplay
* contain a bundle identifier that should be used to translate the * contain a bundle identifier that should be used to translate the
* message text. * message text.
* @param message the text of the message. * @param message the text of the message.
* @param mode the mode of the speak (@see ChatCodes.DEFAULT_MODE
* @see ChatCodes.THINK_MODE,
* @see ChatCodes.EMOTE_MODE ).
*/ */
public void displaySpeakMessage ( public void displaySpeakMessage (
String type, String speaker, String bundle, String message); String type, String speaker, String bundle, String message,
String mode);
/** /**
* Called to display a tell message. A tell message is one that is * Called to display a tell message. A tell message is one that is
@@ -1,5 +1,5 @@
// //
// $Id: ChatCodes.java,v 1.7 2002/04/15 16:28:01 shaper Exp $ // $Id: ChatCodes.java,v 1.8 2002/07/22 22:26:26 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat;
@@ -45,6 +45,17 @@ public interface ChatCodes extends InvocationCodes
/** The message identifier for a tell notification. */ /** The message identifier for a tell notification. */
public static final String TELL_NOTIFICATION = "Tell"; public static final String TELL_NOTIFICATION = "Tell";
/** The default mode used by speak requests. */
public static final String DEFAULT_MODE = "default";
/** The think mode to indicate that the user is thinking
* what they're saying, or is it that they're saying what they're
* thinking? */
public static final String THINK_MODE = "think";
/** The mode to indicate that a speak is actually an emote. */
public static final String EMOTE_MODE = "emote";
/** An error code delivered when the user targeted for a tell /** An error code delivered when the user targeted for a tell
* notification is not online. */ * notification is not online. */
public static final String USER_NOT_ONLINE = "m.user_not_online"; public static final String USER_NOT_ONLINE = "m.user_not_online";
@@ -1,5 +1,5 @@
// //
// $Id: ChatProvider.java,v 1.10 2002/04/30 17:27:30 mdb Exp $ // $Id: ChatProvider.java,v 1.11 2002/07/22 22:26:26 ray Exp $
package com.threerings.crowd.chat; package com.threerings.crowd.chat;
@@ -83,12 +83,36 @@ public class ChatProvider
*/ */
public static void sendChatMessage ( public static void sendChatMessage (
int placeOid, String speaker, String bundle, String message) int placeOid, String speaker, String bundle, String message)
{
sendChatMessage(
placeOid, speaker, bundle, message, ChatCodes.DEFAULT_MODE);
}
/**
* Sends a chat notification to the specified place object originating
* with the specified speaker (the speaker optionally being a server
* entity that wishes to fake a "speak" message) and with the supplied
* message content.
*
* @param placeOid the place to which to deliver the chat message.
* @param speaker the username of the user that generated the message
* (or some special speaker name for server messages).
* @param bundle null when the message originates from a real human,
* the bundle identifier that will be used by the client to translate
* the message text when the message originates from a server entity
* "faking" a chat message.
* @param message the text of the chat message.
* @param mode the mode of the message, @see ChatCodes.DEFAULT_MODE
*/
public static void sendChatMessage (
int placeOid, String speaker, String bundle, String message,
String mode)
{ {
Object[] outargs = null; Object[] outargs = null;
if (bundle == null) { if (bundle == null) {
outargs = new Object[] { speaker, message }; outargs = new Object[] { speaker, message, mode };
} else { } else {
outargs = new Object[] { speaker, bundle, message }; outargs = new Object[] { speaker, bundle, message, mode };
} }
MessageEvent nevt = new MessageEvent( MessageEvent nevt = new MessageEvent(
placeOid, ChatService.SPEAK_NOTIFICATION, outargs); placeOid, ChatService.SPEAK_NOTIFICATION, outargs);
@@ -1,5 +1,5 @@
// //
// $Id: ChatPanel.java,v 1.15 2002/07/17 20:53:31 shaper Exp $ // $Id: ChatPanel.java,v 1.16 2002/07/22 22:26:26 ray Exp $
package com.threerings.micasa.client; package com.threerings.micasa.client;
@@ -226,7 +226,7 @@ public class ChatPanel
// documentation inherited // documentation inherited
public void displaySpeakMessage ( public void displaySpeakMessage (
String type, String speaker, String bundle, String message) String type, String speaker, String bundle, String message, String mode)
{ {
// wrap the speaker in brackets // wrap the speaker in brackets
speaker = "<" + speaker + "> "; speaker = "<" + speaker + "> ";
@@ -1,5 +1,5 @@
// //
// $Id: SpotSceneDirector.java,v 1.14 2002/06/14 01:40:16 ray Exp $ // $Id: SpotSceneDirector.java,v 1.15 2002/07/22 22:26:26 ray Exp $
package com.threerings.whirled.spot.client; package com.threerings.whirled.spot.client;
@@ -12,6 +12,7 @@ import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.ObjectAccessException; import com.threerings.presents.dobj.ObjectAccessException;
import com.threerings.presents.dobj.Subscriber; import com.threerings.presents.dobj.Subscriber;
import com.threerings.crowd.chat.ChatCodes;
import com.threerings.crowd.chat.ChatDirector; import com.threerings.crowd.chat.ChatDirector;
import com.threerings.crowd.client.LocationAdapter; import com.threerings.crowd.client.LocationAdapter;
import com.threerings.crowd.client.LocationDirector; import com.threerings.crowd.client.LocationDirector;
@@ -205,6 +206,18 @@ public class SpotSceneDirector
* are not in a valid cluster and refused to deliver the request. * are not in a valid cluster and refused to deliver the request.
*/ */
public boolean requestClusterSpeak (String message) public boolean requestClusterSpeak (String message)
{
return requestClusterSpeak(message, ChatCodes.DEFAULT_MODE);
}
/**
* Sends a chat message to the other users in the cluster to which the
* location that we currently occupy belongs.
*
* @return true if a cluster speak message was delivered, false if we
* are not in a valid cluster and refused to deliver the request.
*/
public boolean requestClusterSpeak (String message, String mode)
{ {
// make sure we're currently in a scene // make sure we're currently in a scene
DisplaySpotScene scene = (DisplaySpotScene)_scdir.getScene(); DisplaySpotScene scene = (DisplaySpotScene)_scdir.getScene();
@@ -231,7 +244,7 @@ public class SpotSceneDirector
// we're all clear to go // we're all clear to go
SpotService.clusterSpeak( SpotService.clusterSpeak(
_ctx.getClient(), scene.getId(), _locationId, message, this); _ctx.getClient(), scene.getId(), _locationId, message, mode, this);
return true; return true;
} }
@@ -1,5 +1,5 @@
// //
// $Id: SpotService.java,v 1.8 2002/05/15 23:54:34 mdb Exp $ // $Id: SpotService.java,v 1.9 2002/07/22 22:26:26 ray Exp $
package com.threerings.whirled.spot.client; package com.threerings.whirled.spot.client;
@@ -56,11 +56,11 @@ public class SpotService implements SpotCodes
*/ */
public static void clusterSpeak ( public static void clusterSpeak (
Client client, int sceneId, int locationId, String message, Client client, int sceneId, int locationId, String message,
SpotSceneDirector rsptarget) String mode, SpotSceneDirector rsptarget)
{ {
InvocationDirector invdir = client.getInvocationDirector(); InvocationDirector invdir = client.getInvocationDirector();
Object[] args = new Object[] { Object[] args = new Object[] {
new Integer(sceneId), new Integer(locationId), message }; new Integer(sceneId), new Integer(locationId), message, mode };
invdir.invoke(MODULE_NAME, CLUSTER_SPEAK_REQUEST, args, rsptarget); invdir.invoke(MODULE_NAME, CLUSTER_SPEAK_REQUEST, args, rsptarget);
Log.debug("Sent clusterSpeak request [sceneId=" + sceneId + Log.debug("Sent clusterSpeak request [sceneId=" + sceneId +
", locId=" + locationId + ", message=" + message + "]."); ", locId=" + locationId + ", message=" + message + "].");
@@ -1,5 +1,5 @@
// //
// $Id: SpotProvider.java,v 1.10 2002/06/20 22:38:58 mdb Exp $ // $Id: SpotProvider.java,v 1.11 2002/07/22 22:26:26 ray Exp $
package com.threerings.whirled.spot.server; package com.threerings.whirled.spot.server;
@@ -194,10 +194,11 @@ public class SpotProvider extends InvocationProvider
* Handles {@link SpotCodes#CLUSTER_SPEAK_REQUEST} messages. * Handles {@link SpotCodes#CLUSTER_SPEAK_REQUEST} messages.
*/ */
public void handleClusterSpeakRequest ( public void handleClusterSpeakRequest (
BodyObject source, int invid, int sceneId, int locId, String message) BodyObject source, int invid, int sceneId, int locId, String message,
String mode)
{ {
sendClusterChatMessage(sceneId, locId, source.getOid(), sendClusterChatMessage(sceneId, locId, source.getOid(),
source.username, null, message); source.username, null, message, mode);
} }
/** /**
@@ -221,7 +222,7 @@ public class SpotProvider extends InvocationProvider
*/ */
public static void sendClusterChatMessage ( public static void sendClusterChatMessage (
int sceneId, int locId, int speakerOid, String speaker, int sceneId, int locId, int speakerOid, String speaker,
String bundle, String message) String bundle, String message, String mode)
{ {
// look up the scene manager for the specified scene // look up the scene manager for the specified scene
SpotSceneManager smgr = (SpotSceneManager) SpotSceneManager smgr = (SpotSceneManager)
@@ -237,7 +238,7 @@ public class SpotProvider extends InvocationProvider
// need to check that the location exists and that the speaker // need to check that the location exists and that the speaker
// occupies it and so on // occupies it and so on
smgr.handleClusterSpeakRequest( smgr.handleClusterSpeakRequest(
speakerOid, speaker, locId, bundle, message); speakerOid, speaker, locId, bundle, message, mode);
} }
} }
@@ -1,5 +1,5 @@
// //
// $Id: SpotSceneManager.java,v 1.13 2002/06/20 23:06:40 mdb Exp $ // $Id: SpotSceneManager.java,v 1.14 2002/07/22 22:26:26 ray Exp $
package com.threerings.whirled.spot.server; package com.threerings.whirled.spot.server;
@@ -218,7 +218,7 @@ public class SpotSceneManager extends SceneManager
*/ */
protected void handleClusterSpeakRequest ( protected void handleClusterSpeakRequest (
int sourceOid, String source, int locationId, int sourceOid, String source, int locationId,
String bundle, String message) String bundle, String message, String mode)
{ {
// make sure this user occupies the specified location // make sure this user occupies the specified location
int locidx = _sscene.getLocationIndex(locationId); int locidx = _sscene.getLocationIndex(locationId);
@@ -243,7 +243,8 @@ public class SpotSceneManager extends SceneManager
// all is well, generate a chat notification // all is well, generate a chat notification
int clusterOid = _clusterOids[clusterIndex]; int clusterOid = _clusterOids[clusterIndex];
if (clusterOid > 0) { if (clusterOid > 0) {
ChatProvider.sendChatMessage(clusterOid, source, bundle, message); ChatProvider.sendChatMessage(
clusterOid, source, bundle, message, mode);
} else { } else {
Log.warning("Have no cluster object for CCREQ " + Log.warning("Have no cluster object for CCREQ " +