Go back to defaultly broadcasting to game objects, in case someone ever

creates a traditional lobby->room server with narya, and instead allow
a broadcast object to be registered with the ChatProvider to which all
broadcasts will be sent.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3261 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2004-12-03 23:47:19 +00:00
parent 33df387517
commit feb7355804
3 changed files with 44 additions and 30 deletions
@@ -1,5 +1,5 @@
//
// $Id: ChatProvider.java,v 1.30 2004/08/27 02:12:32 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -30,6 +30,7 @@ import com.threerings.util.TimeUtil;
import com.threerings.presents.client.InvocationService.InvocationListener;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.server.InvocationException;
@@ -86,6 +87,18 @@ public class ChatProvider
_comAuth = comAuth;
}
/**
* Set an object to which all broadcasts should be sent, rather
* than iterating over the place objects and sending to each of them.
*
* @param object an object to send all broadcasts, or null to send to
* each place object instead.
*/
public static void setAlternateBroadcastObject (DObject object)
{
_broadcastObject = object;
}
/**
* Initializes the chat services and registers a chat provider with
* the invocation manager.
@@ -176,25 +189,39 @@ public class ChatProvider
public static void broadcast (Name from, String bundle, String msg,
boolean attention)
{
Iterator iter = CrowdServer.plreg.enumeratePlaces();
while (iter.hasNext()) {
PlaceObject plobj = (PlaceObject)iter.next();
if (plobj.shouldBroadcast()) {
if (from == null) {
if (attention) {
SpeakProvider.sendAttention(plobj, bundle, msg);
} else {
SpeakProvider.sendInfo(plobj, bundle, msg);
}
if (_broadcastObject != null) {
broadcastTo(_broadcastObject, from, bundle, msg, attention);
} else {
SpeakProvider.sendSpeak(plobj, from, bundle, msg,
BROADCAST_MODE);
} else {
Iterator iter = CrowdServer.plreg.enumeratePlaces();
while (iter.hasNext()) {
PlaceObject plobj = (PlaceObject)iter.next();
if (plobj.shouldBroadcast()) {
broadcastTo(plobj, from, bundle, msg, attention);
}
}
}
}
/**
* Direct a broadcast to the specified object.
*/
protected static void broadcastTo (DObject object,
Name from, String bundle, String msg, boolean attention)
{
if (from == null) {
if (attention) {
SpeakProvider.sendAttention(object, bundle, msg);
} else {
SpeakProvider.sendInfo(object, bundle, msg);
}
} else {
SpeakProvider.sendSpeak(object, from, bundle, msg,
BROADCAST_MODE);
}
}
/**
* Processes a {@link ClientService#away} request.
*/
@@ -239,4 +266,7 @@ public class ChatProvider
/** The entity that will authorize our chatters. */
protected static CommunicationAuthorizer _comAuth;
/** An alternative object to which broadcasts should be sent. */
protected static DObject _broadcastObject;
}
@@ -75,14 +75,6 @@ public class GameObject extends PlaceObject
/** The player index of the creating player if this is a party game. */
public int creator;
// documentation inherited
public boolean shouldBroadcast ()
{
// we do not broadcast to games because the users will get it
// on their scene objects
return false;
}
/**
* Returns the number of players in the game.
*/
@@ -96,14 +96,6 @@ public class GameObject extends PlaceObject
/** The player index of the creating player if this is a party game. */
public int creator;
// documentation inherited
public boolean shouldBroadcast ()
{
// we do not broadcast to games because the users will get it
// on their scene objects
return false;
}
/**
* Returns the number of players in the game.
*/