org.elkoserver.server.context.mods
Class PrivateChat

java.lang.Object
  extended by org.elkoserver.server.context.Mod
      extended by org.elkoserver.server.context.mods.PrivateChat
All Implemented Interfaces:
Cloneable, DispatchTarget, Encodable, UserMod

public class PrivateChat
extends Mod
implements UserMod

Mod to enable users in a context to chat privately with each other. This mod must be attached to a user, but note that it is not to be attached to the user record in the object database. It never persists, but is always attached dynamically by a Chat mod attached to the context.

See Also:
Chat

Constructor Summary
PrivateChat(boolean allowPrivate, boolean allowPush)
          Constructor.
 
Method Summary
 JSONLiteral encode(EncodeControl control)
          Encode this mod for transmission or persistence.
 void push(User from, String url, OptString frame, OptString features)
          Message handler for the 'push' message.
 void say(User from, String text)
          Message handler for the 'say' message.
 
Methods inherited from class org.elkoserver.server.context.Mod
attachTo, clone, context, ensureHolding, ensureInContext, ensureReachable, ensureSameContext, ensureSameUser, holder, isEphemeral, markAsChanged, markAsEphemeral, object
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrivateChat

public PrivateChat(boolean allowPrivate,
                   boolean allowPush)
Constructor. Initialization parameters configuring the specific chat operations this mod will enable. Note that setting both 'allowPrivate' and 'allowPush' to false is permitted but not useful.

Parameters:
allowPrivate - If true, users can chat privately, i.e., transmit utterances to other individual users.
allowPush - If true, users can push URLs privately, i.e., to other individual users.
Method Detail

encode

public JSONLiteral encode(EncodeControl control)
Encode this mod for transmission or persistence. Note that this mod is never persisted or transmitted.

Specified by:
encode in interface Encodable
Parameters:
control - Encode control determining what flavor of encoding should be done.
Returns:
null since this mod is never persisted or transmitted.

push

@JSONMethod(value={"url","frame","features"})
public void push(User from,
                                 String url,
                                 OptString frame,
                                 OptString features)
          throws MessageHandlerException
Message handler for the 'push' message.

This message pushes a URL to the user this mod is attached to. This is done by echoing the 'push' message to the target user, marked as being from the user who sent it.

recv: { to:REF, op:"push", url:STR, frame:optSTR, features:optSTR }
send: { to:REF, op:"push", url:STR, frame:optSTR, features:optSTR, from:REF }

Parameters:
url - The URL being pushed.
frame - Optional name of a frame to push it to.
features - Optional features string to associate with it.
Throws:
MessageHandlerException - if 'from' is not in the same context as this mod or if the 'allowPush' constructor parameter was false.

say

@JSONMethod(value="text")
public void say(User from,
                                String text)
         throws MessageHandlerException
Message handler for the 'say' message.

This message transmits chat text to the user this mod is attached to. This is done by echoing the 'say' message to the target user, marked as being from the user who sent it.

recv: { to:REF, op:"say", text:STR }
send: { to:REF, op:"say", text:STR, from:REF }

Parameters:
text - The chat text being "spoken".
Throws:
MessageHandlerException - if 'from' is not in the same context as this mod or if the 'allowPrivate' constructor parameter was false.