Added facilities for sending system messages to places which are like
speak messages but come from the server and are displayed differently (like in all red or something because these will say things like "The system is shutting down in five minutes.") git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@501 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatDirector.java,v 1.11 2001/10/12 00:03:02 mdb Exp $
|
||||
// $Id: ChatDirector.java,v 1.12 2001/10/18 23:55:24 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.chat;
|
||||
|
||||
@@ -143,6 +143,8 @@ public class ChatDirector
|
||||
String name = event.getName();
|
||||
if (name.equals(ChatService.SPEAK_NOTIFICATION)) {
|
||||
handleSpeakMessage(event.getArgs());
|
||||
} else if (name.equals(ChatService.SYSTEM_NOTIFICATION)) {
|
||||
handleSystemMessage(event.getArgs());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,6 +202,17 @@ public class ChatDirector
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleSystemMessage (Object[] args)
|
||||
{
|
||||
String message = (String)args[0];
|
||||
|
||||
// pass this on to our chat displays
|
||||
for (int i = 0; i < _displays.size(); i++) {
|
||||
ChatDisplay display = (ChatDisplay)_displays.get(i);
|
||||
display.displaySystemMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
protected CrowdContext _ctx;
|
||||
protected PlaceObject _place;
|
||||
protected ArrayList _displays = new ArrayList();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatDisplay.java,v 1.3 2001/10/11 04:07:51 mdb Exp $
|
||||
// $Id: ChatDisplay.java,v 1.4 2001/10/18 23:55:24 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.chat;
|
||||
|
||||
@@ -32,6 +32,17 @@ public interface ChatDisplay
|
||||
*/
|
||||
public void displayTellMessage (String speaker, String message);
|
||||
|
||||
/**
|
||||
* Called to display a system message. A system message is one that is
|
||||
* broadcast to all occupants of a particular place and rather than
|
||||
* originating from some other user in the place, originates from the
|
||||
* server and should be displayed visually differently from speak
|
||||
* messages.
|
||||
*
|
||||
* @param message the text of the message.
|
||||
*/
|
||||
public void displaySystemMessage (String message);
|
||||
|
||||
/**
|
||||
* Called in response to a chat request (either speak or tell) that
|
||||
* originated on this client. The request id supplied will match the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatCodes.java,v 1.2 2001/10/11 04:07:51 mdb Exp $
|
||||
// $Id: ChatCodes.java,v 1.3 2001/10/18 23:55:24 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.chat;
|
||||
|
||||
@@ -19,6 +19,9 @@ public interface ChatCodes extends InvocationCodes
|
||||
/** The message identifier for a speak notification message. */
|
||||
public static final String SPEAK_NOTIFICATION = "spknot";
|
||||
|
||||
/** The message identifier for a system notification message. */
|
||||
public static final String SYSTEM_NOTIFICATION = "sysnot";
|
||||
|
||||
/** The message identifier for a tell request. */
|
||||
public static final String TELL_REQUEST = "Tell";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ChatProvider.java,v 1.6 2001/10/18 20:51:59 mdb Exp $
|
||||
// $Id: ChatProvider.java,v 1.7 2001/10/18 23:55:24 mdb Exp $
|
||||
|
||||
package com.threerings.crowd.chat;
|
||||
|
||||
@@ -55,4 +55,21 @@ public class ChatProvider
|
||||
placeOid, ChatService.SPEAK_NOTIFICATION, outargs);
|
||||
CrowdServer.omgr.postEvent(nevt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a system message notification to the specified place object
|
||||
* with the supplied message content. A system message is one that
|
||||
* will be rendered where the chat messages are rendered, but in a way
|
||||
* that makes it clear that it is a message from the server.
|
||||
*
|
||||
* @param placeOid the place to which to deliver the message.
|
||||
* @param message the text of the message.
|
||||
*/
|
||||
public static void sendSystemMessage (int placeOid, String message)
|
||||
{
|
||||
Object[] outargs = new Object[] { message };
|
||||
MessageEvent nevt = new MessageEvent(
|
||||
placeOid, ChatService.SYSTEM_NOTIFICATION, outargs);
|
||||
CrowdServer.omgr.postEvent(nevt);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user