org.elkoserver.server.context
Class Msg

java.lang.Object
  extended by org.elkoserver.server.context.Msg

public class Msg
extends Object

Utility class consisting of static methods that generate various generally useful messages that can be sent to the client. These messages are sent by a number of different classes, including, potentially, application-defined Mod classes, so the methods to construct these messages don't naturally belong with any particular server abstraction. Hence this bag of miscellany.


Method Summary
static JSONLiteral msgDelete(Referenceable target)
          Create a 'delete' message.
static JSONLiteral msgError(Referenceable target, String op, String error)
          Create an 'error' message.
static JSONLiteral msgMake(Referenceable target, BasicObject obj)
          Create a 'make' message with a default creator.
static JSONLiteral msgMake(Referenceable target, BasicObject obj, String sess)
          Create a 'make' message with a default creator and explicit session identifier.
static JSONLiteral msgMake(Referenceable target, BasicObject obj, User maker)
          Create a 'make' message.
static JSONLiteral msgMake(Referenceable target, BasicObject obj, User maker, boolean you, String sess)
          Create a 'make' message.
static JSONLiteral msgPush(Referenceable target, Referenceable from, String url, String frame, String features)
          Create a 'push' message.
static JSONLiteral msgSay(Referenceable target, Referenceable from, String text)
          Create a 'say' message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

msgDelete

public static JSONLiteral msgDelete(Referenceable target)
Create a 'delete' message. This directs a client to delete an object.

Parameters:
target - Object the message is being sent to (the object being deleted).

msgError

public static JSONLiteral msgError(Referenceable target,
                                   String op,
                                   String error)
Create an 'error' message. This informs the client that something went wrong.

Parameters:
target - Object the message is being sent to (the object being informed).

msgMake

public static JSONLiteral msgMake(Referenceable target,
                                  BasicObject obj,
                                  User maker,
                                  boolean you,
                                  String sess)
Create a 'make' message. This directs a client to create an object.

Parameters:
target - Object the message is being sent to (the object that is to be the container of the new object).
obj - The object that is to be created by the client.
maker - The user who is to be represented as the creator of the object, or null if none is.
you - If true, object being made is its recipient.
sess - The client context session ID, or null if there is none.

msgMake

public static JSONLiteral msgMake(Referenceable target,
                                  BasicObject obj,
                                  User maker)
Create a 'make' message. This directs a client to create an object. This method is a notational convenience; it is equivalent to the five-argument 'make' with the 'you' parameter set to false (which is, by far, the typical case) and no context session ID.

Parameters:
target - Object the message is being sent to (the object that is to be the container of the new object).
obj - The object that is to be created by the client.
maker - The user who is to be represented as the creator of the object, or null if none is.

msgMake

public static JSONLiteral msgMake(Referenceable target,
                                  BasicObject obj,
                                  String sess)
Create a 'make' message with a default creator and explicit session identifier. This method is exactly equivalent to:

msgMake(target, obj, null, false, sess)

and is provided just for convenience.

Parameters:
target - Object the message is being sent to (the object that is to be the container of the new object).
obj - The object that is to be created by the client.
sess - The client context session ID, or null if there is none.

msgMake

public static JSONLiteral msgMake(Referenceable target,
                                  BasicObject obj)
Create a 'make' message with a default creator. This method is exactly equivalent to:

msgMake(target, obj, null, false, null)

and is provided just for convenience.

Parameters:
target - Object the message is being sent to (the object that is to be the container of the new object).
obj - The object that is to be created by the client.

msgPush

public static JSONLiteral msgPush(Referenceable target,
                                  Referenceable from,
                                  String url,
                                  String frame,
                                  String features)
Create a 'push' message. This directs a client to push the browser to a different URL than the one it is looking at.

Parameters:
target - Object the message is being sent to (normally this will be a user or context).
from - Object the message is to be alleged to be from, or null if not relevant. This normally indicates the user who is doing the pushing.
url - The URL being pushed.
frame - Name of a frame to push the URL into, or null if not relevant.
features - Features string to associate with the URL, or null if not relevant.

msgSay

public static JSONLiteral msgSay(Referenceable target,
                                 Referenceable from,
                                 String text)
Create a 'say' message. This directs a client to display chat text.

Parameters:
target - Object the message is being sent to (normally this will be a user or context).
from - Object the message is to be alleged to be from, or null if not relevant. This normally indicates the user who is speaking.
text - The text to be said.