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:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatDirector.java,v 1.36 2002/10/30 01:47:12 ray Exp $
|
||||
// $Id: ChatDirector.java,v 1.37 2002/10/31 23:27:16 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.chat;
|
||||
|
||||
@@ -290,6 +290,23 @@ public class ChatDirector extends BasicDirector
|
||||
speakService.speak(_ctx.getClient(), message, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests to send a site-wide broadcast message.
|
||||
*
|
||||
* @param message the contents of the message.
|
||||
*/
|
||||
public void requestBroadcast (String message)
|
||||
{
|
||||
_cservice.broadcast(
|
||||
_ctx.getClient(), message, new ChatService.InvocationListener () {
|
||||
public void requestFailed (String reason) {
|
||||
displayFeedbackMessage(
|
||||
_bundle, MessageBundle.compose(
|
||||
"m.broadcast_failed", reason));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that a tell message be delivered to the specified target
|
||||
* user.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatService.java,v 1.9 2002/10/30 01:47:12 ray Exp $
|
||||
// $Id: ChatService.java,v 1.10 2002/10/31 23:27:16 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.chat;
|
||||
|
||||
@@ -45,4 +45,14 @@ public interface ChatService extends InvocationService
|
||||
*/
|
||||
public void tell (Client client, String target, String message,
|
||||
TellListener listener);
|
||||
|
||||
/**
|
||||
* Requests that a message be broadcast to all users in the system.
|
||||
*
|
||||
* @param client a connected, operational client instance.
|
||||
* @param message the contents of the message.
|
||||
* @param listener the reference that will receive a failure response.
|
||||
*/
|
||||
public void broadcast (Client client, String message,
|
||||
InvocationListener listener);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatCodes.java,v 1.12 2002/10/30 01:47:12 ray Exp $
|
||||
// $Id: ChatCodes.java,v 1.13 2002/10/31 23:27:16 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.chat;
|
||||
|
||||
@@ -38,6 +38,10 @@ public interface ChatCodes extends InvocationCodes
|
||||
* actually an emote. */
|
||||
public static final byte EMOTE_MODE = 2;
|
||||
|
||||
/** A {@link SpeakService#speak} mode to indicate that a speak is
|
||||
* actually a server-wide broadcast. */
|
||||
public static final byte BROADCAST_MODE = 3;
|
||||
|
||||
/** An error code delivered when the user targeted for a tell
|
||||
* notification is not online. */
|
||||
public static final String USER_NOT_ONLINE = "m.user_not_online";
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
//
|
||||
// $Id: ChatMarshaller.java,v 1.3 2002/10/30 01:47:12 ray Exp $
|
||||
// $Id: ChatMarshaller.java,v 1.4 2002/10/31 23:27:16 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.chat;
|
||||
|
||||
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.InvocationMarshaller;
|
||||
import com.threerings.presents.dobj.InvocationResponseEvent;
|
||||
|
||||
@@ -80,5 +81,18 @@ public class ChatMarshaller extends InvocationMarshaller
|
||||
});
|
||||
}
|
||||
|
||||
// Generated on 17:55:05 10/29/02.
|
||||
/** The method id used to dispatch {@link #broadcast} requests. */
|
||||
public static final int BROADCAST = 2;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void broadcast (Client arg1, String arg2, InvocationListener arg3)
|
||||
{
|
||||
ListenerMarshaller listener3 = new ListenerMarshaller();
|
||||
listener3.listener = arg3;
|
||||
sendRequest(arg1, BROADCAST, new Object[] {
|
||||
arg2, listener3
|
||||
});
|
||||
}
|
||||
|
||||
// Generated on 13:40:31 10/31/02.
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user