Added broadcast chat mechanism.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1875 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-10-31 23:27:16 +00:00
parent 35f3173694
commit dd4b1c69c3
6 changed files with 93 additions and 11 deletions
@@ -1,5 +1,5 @@
//
// $Id: ChatDispatcher.java,v 1.3 2002/10/30 01:47:12 ray Exp $
// $Id: ChatDispatcher.java,v 1.4 2002/10/31 23:27:16 mdb Exp $
package com.threerings.crowd.chat;
@@ -7,6 +7,7 @@ import com.threerings.crowd.chat.ChatMarshaller;
import com.threerings.crowd.chat.ChatService;
import com.threerings.crowd.chat.ChatService.TellListener;
import com.threerings.presents.client.Client;
import com.threerings.presents.client.InvocationService.InvocationListener;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationMarshaller;
import com.threerings.presents.server.InvocationDispatcher;
@@ -45,10 +46,17 @@ public class ChatDispatcher extends InvocationDispatcher
);
return;
case ChatMarshaller.BROADCAST:
((ChatProvider)provider).broadcast(
source,
(String)args[0], (InvocationListener)args[1]
);
return;
default:
super.dispatchRequest(source, methodId, args);
}
}
// Generated on 17:55:05 10/29/02.
// Generated on 13:40:31 10/31/02.
}
@@ -1,8 +1,14 @@
//
// $Id: ChatProvider.java,v 1.15 2002/10/30 01:56:17 ray Exp $
// $Id: ChatProvider.java,v 1.16 2002/10/31 23:27:16 mdb Exp $
package com.threerings.crowd.chat;
import java.util.Iterator;
import com.threerings.util.MessageBundle;
import com.threerings.util.TimeUtil;
import com.threerings.presents.client.InvocationService.InvocationListener;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.MessageEvent;
@@ -14,13 +20,11 @@ import com.threerings.presents.server.InvocationProvider;
import com.threerings.crowd.Log;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer;
import com.threerings.crowd.chat.ChatService.TellListener;
import com.threerings.util.MessageBundle;
import com.threerings.util.TimeUtil;
/**
* The chat provider handles the server side of the chat-related
* invocation services.
@@ -28,6 +32,9 @@ import com.threerings.util.TimeUtil;
public class ChatProvider
implements ChatCodes, InvocationProvider
{
/** The access control identifier for broadcast chat privileges. */
public static final String BROADCAST_TOKEN = "crowd.chat.broadcast";
/**
* Initializes the chat services and registers a chat provider with
* the invocation manager.
@@ -77,6 +84,28 @@ public class ChatProvider
}
}
/**
* Processes a {@link ClientService#broadcast} request.
*/
public void broadcast (ClientObject caller, String message,
InvocationListener listener)
throws InvocationException
{
BodyObject body = (BodyObject)caller;
// make sure the requesting user has broadcast privileges
if (CrowdServer.actrl.checkAccess(body, BROADCAST_TOKEN)) {
throw new InvocationException(ACCESS_DENIED);
}
Iterator iter = CrowdServer.plreg.enumeratePlaces();
while (iter.hasNext()) {
PlaceObject plobj = (PlaceObject)iter.next();
SpeakProvider.sendSpeak(plobj, body.username, null,
message, BROADCAST_MODE);
}
}
/**
* Delivers a tell notification to the specified target player,
* originating with the specified speaker.