org.elkoserver.server.context.mods
Class TalkPrefs

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

public class TalkPrefs
extends Mod
implements ObjectCompletionWatcher, UserMod

Mod to hold a user's current chat text display style settings. This is used to allow text chat to be conducted with user-configurable styled text. It operates in conjunction with TalkOptions and Chat mods that should be attached to the context the user is in. This mod gets attached to a user, but note that it is not normally attached to the user record in the object database. It does not persist, but instead is attached dynamically by the TalkOptions mod.


Constructor Summary
TalkPrefs(StyleDesc style)
          JSON-driven constructor.
 
Method Summary
 JSONLiteral encode(EncodeControl control)
          Encode this mod for transmission or persistence.
 void objectIsComplete()
          Upon completion of the user object to which this mod attached, grab the next set of available style choices from the context's TalkOptions mod.
 void style(User from, OptString color, OptString backgroundColor, OptString icon, OptString textStyle)
          Message handler for the 'style' 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

TalkPrefs

@JSONMethod(value="style")
public TalkPrefs(StyleDesc style)
JSON-driven constructor. Note that although this method takes a 'style' parameter, normally styles are initialized (in the objectIsComplete() method) by choosing, in a round-robin fashion, from the style options available in in the context's TalkOptions mod.

Parameters:
style - The StyleDesc associated with the chat text of the user to whom this mod is attached.
Method Detail

encode

public JSONLiteral encode(EncodeControl control)
Encode this mod for transmission or persistence.

Specified by:
encode in interface Encodable
Parameters:
control - Encode control determining what flavor of encoding should be done.
Returns:
a JSON literal representing this mod.

objectIsComplete

public void objectIsComplete()
Upon completion of the user object to which this mod attached, grab the next set of available style choices from the context's TalkOptions mod.

Application code should not call this method.

Specified by:
objectIsComplete in interface ObjectCompletionWatcher

style

@JSONMethod(value={"color","backgroundColor","icon","textStyle"})
public void style(User from,
                                  OptString color,
                                  OptString backgroundColor,
                                  OptString icon,
                                  OptString textStyle)
           throws MessageHandlerException
Message handler for the 'style' message.

This is a request from a client to change one or more of the style attributes. If the change operation is successful, a corresponding 'style' message is broadcast to the context.

recv: { to:REF, op:"style", color:optSTR, backgroundColor:optSTR, icon:optSTR, textStyle:optSTR }
send: { to:REF, op:"style", color:optSTR, backgroundColor:optSTR, icon:optSTR, textStyle:optSTR }

Parameters:
from - The user who sent the message.
color - New text color value (optional).
backgroundColor - New background color value (optional).
icon - New icon URL string (optional).
textStyle - New typeface/style info (optional).
Throws:
MessageHandlerException - if 'from' is not in the same user this mod is attached to.