public class Chat extends Mod implements ObjectCompletionWatcher, ContextMod
PrivateChat
Constructor and Description |
---|
Chat(OptBoolean allowChat,
OptBoolean allowPrivate,
OptBoolean allowPush,
OptBoolean allowPrivatePush)
JSON-driven constructor.
|
Modifier and Type | Method and Description |
---|---|
JSONLiteral |
encode(EncodeControl control)
Encode this mod for transmission or persistence.
|
void |
objectIsComplete()
If this mod's configuration enables private chat and/or private push,
arrange to automatically attach ephemeral
PrivateChat mods to
arriving users. |
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.
|
attachTo, clone, context, ensureHolding, ensureInContext, ensureReachable, ensureSameContext, ensureSameUser, holder, isEphemeral, markAsChanged, markAsEphemeral, object
@JSONMethod(value={"allowchat","allowprivate","allowpush","allowprivatepush"}) public Chat(OptBoolean allowChat, OptBoolean allowPrivate, OptBoolean allowPush, OptBoolean allowPrivatePush)
If 'allowPrivate' or 'allowPrivatePush' is true, this mod will
automatically attach a correspondingly configured ephemeral PrivateChat
mod to any user who enters the context.
Note that setting all four 'allow' parameters to false is permitted but not useful.
allowChat
- If true, users can chat publicly, i.e., issue
utterances that are broadcast to everyone in the context.allowPrivate
- If true, users can chat privately, i.e., transmit
utterances to other individual users.allowPush
- If true, users can push URLs publicly, i.e., to
everyone in the context.allowPrivatePush
- If true, users can push URLs privately, i.e.,
to other individual users.public JSONLiteral encode(EncodeControl control)
public void objectIsComplete()
PrivateChat
mods to
arriving users.
Application code should not call this method.
objectIsComplete
in interface ObjectCompletionWatcher
@JSONMethod(value={"url","frame","features"}) public void push(User from, String url, OptString frame, OptString features) throws MessageHandlerException
This message pushes a URL to everyone in the context. This is done by echoing the 'push' message to the context, 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 }
url
- The URL being pushed.frame
- Optional name of a frame to push it to.features
- Optional features string to associate with it.MessageHandlerException
- if 'from' is not in the same context as
this mod or if the 'allowPush' configuration was parameter false.@JSONMethod(value="text") public void say(User from, String text) throws MessageHandlerException
This message broadcasts chat text to everyone in the context. This is done by echoing the 'say' message to the context, marked as being from the user who sent it.
recv: { to:REF, op:"say", text:STR }
send: { to:REF, op:"say", text:STR,
from:fromREF }
text
- The chat text being "spoken".MessageHandlerException
- if 'from' is not in the same context as
this mod or if the 'allowChat' configuration parameter was false.Copyright © 2017. All rights reserved.