Localized chat! Server entities may now fake speak and tell messages that
are translated by the client upon receipt. We love to translate. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1319 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SpotProvider.java,v 1.6 2002/04/15 16:28:03 shaper Exp $
|
||||
// $Id: SpotProvider.java,v 1.7 2002/04/30 17:27:30 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.spot.server;
|
||||
|
||||
@@ -215,21 +215,49 @@ public class SpotProvider extends InvocationProvider
|
||||
*/
|
||||
public void handleClusterSpeakRequest (
|
||||
BodyObject source, int invid, int sceneId, int locId, String message)
|
||||
{
|
||||
sendClusterChatMessage(sceneId, locId, source.getOid(),
|
||||
source.username, null, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a cluster chat notification to the specified location in the
|
||||
* specified place object originating with the specified speaker (the
|
||||
* speaker can be a server entity that wishes to fake a "speak"
|
||||
* message, in which case the bundle argument should be non-null and
|
||||
* should contain the id of the bundle to be used to translate the
|
||||
* message text) and with the supplied message content.
|
||||
*
|
||||
* @param sceneId the scene id in which to deliver the chat message.
|
||||
* @param locId the location whose cluster will be spoken to.
|
||||
* @param speakerOid the body object id of the speaker (used to verify
|
||||
* that they are in the cluster in question).
|
||||
* @param speaker the username of the user that generated the message
|
||||
* (or some special speaker name for server messages).
|
||||
* @param bundle the bundle identifier that will be used by the client
|
||||
* to translate the message text (or null if the message originated
|
||||
* from a real live human who wrote it in their native tongue).
|
||||
* @param message the text of the chat message.
|
||||
*/
|
||||
public static void sendClusterChatMessage (
|
||||
int sceneId, int locId, int speakerOid, String speaker,
|
||||
String bundle, String message)
|
||||
{
|
||||
// look up the scene manager for the specified scene
|
||||
SpotSceneManager smgr = (SpotSceneManager)
|
||||
_screg.getSceneManager(sceneId);
|
||||
if (smgr == null) {
|
||||
Log.warning("User requested cluster chat in " +
|
||||
"non-existent scene [user=" + source.username +
|
||||
"non-existent scene [user=" + speaker +
|
||||
", sceneId=" + sceneId + ", locId=" + locId +
|
||||
", message=" + message + "].");
|
||||
|
||||
} else {
|
||||
// pass this request on to the spot scene manager as it will
|
||||
// need to check that the location exists and that the
|
||||
// requester occupies it and so on
|
||||
smgr.handleClusterSpeakRequest(source, locId, message);
|
||||
// need to check that the location exists and that the speaker
|
||||
// occupies it and so on
|
||||
smgr.handleClusterSpeakRequest(
|
||||
speakerOid, speaker, locId, bundle, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SpotSceneManager.java,v 1.5 2002/04/15 16:28:03 shaper Exp $
|
||||
// $Id: SpotSceneManager.java,v 1.6 2002/04/30 17:27:30 mdb Exp $
|
||||
|
||||
package com.threerings.whirled.spot.server;
|
||||
|
||||
@@ -169,11 +169,12 @@ public class SpotSceneManager extends SceneManager
|
||||
* request.
|
||||
*/
|
||||
protected void handleClusterSpeakRequest (
|
||||
BodyObject source, int locationId, String message)
|
||||
int sourceOid, String source, int locationId,
|
||||
String bundle, String message)
|
||||
{
|
||||
// make sure this user occupies the specified location
|
||||
int locidx = _sscene.getLocationIndex(locationId);
|
||||
if (locidx == -1 || _locationOccs[locidx] != source.getOid()) {
|
||||
if (locidx == -1 || _locationOccs[locidx] != sourceOid) {
|
||||
Log.warning("User not in specified location for CCREQ " +
|
||||
"[body=" + source + ", locId=" + locationId +
|
||||
", message=" + message + "].");
|
||||
@@ -192,12 +193,11 @@ public class SpotSceneManager extends SceneManager
|
||||
// all is well, generate a chat notification
|
||||
int clusterOid = _clusterOids[clusterIndex];
|
||||
if (clusterOid > 0) {
|
||||
ChatProvider.sendChatMessage(clusterOid, source.username, message);
|
||||
ChatProvider.sendChatMessage(clusterOid, source, bundle, message);
|
||||
|
||||
} else {
|
||||
Log.warning("Have no cluster object for CCREQ " +
|
||||
"[cidx=" + clusterIndex +
|
||||
", chatter=" + source.username +
|
||||
"[cidx=" + clusterIndex + ", chatter=" + source +
|
||||
", message=" + message + "].");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user