public class Dictionary extends Mod implements GeneralMod
Constructor and Description |
---|
Dictionary(String[] names,
String[] values,
OptBoolean persist)
JSON-driven constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
delvar(User from,
String[] names)
Message handler for the 'delvar' message.
|
JSONLiteral |
encode(EncodeControl control)
Encode this mod for transmission or persistence.
|
void |
setvar(User from,
String[] names,
String[] values)
Message handle for the 'setvar' message.
|
attachTo, clone, context, ensureHolding, ensureInContext, ensureReachable, ensureSameContext, ensureSameUser, holder, isEphemeral, markAsChanged, markAsEphemeral, object
@JSONMethod(value={"names","values","persist"}) public Dictionary(String[] names, String[] values, OptBoolean persist)
names
- Array of variable names.values
- Parallel array of values for those variables.persist
- If true, make sure any changes get saved to disk; if
false (the default), changes are ephemeral.public JSONLiteral encode(EncodeControl control)
@JSONMethod(value="names") public void delvar(User from, String[] names) throws MessageHandlerException
This message is a request to delete of one or more of the variables from the set. If the operation is successful, a corresponding 'delvar' message is broadcast to the context.
Warning: This message is not secure. As implemented today, anyone can delete variables.
recv: { to:REF, op:"delvar",
names:STR[] }
send: { to:REF, op:"delvar",
names:STR[[ }
from
- The user who sent the message.names
- Names of the variables to remove.MessageHandlerException
- if 'from' is not in the same context as
this mod.@JSONMethod(value={"names","values"}) public void setvar(User from, String[] names, String[] values) throws MessageHandlerException
This message is a request to change the value of one or more of the variables (or to assign a new variable). If the operation is successfull, a corresponding 'setvar' message is broadcast to the context.
Warning: This message is not secure. As implemented today, anyone can modify variables.
recv: { to:REF, op:"setvar", names:STR[],
values:STR[] }
send: { to:REF, op:"setvar", names:STR[],
values:STR[] }
from
- The user who sent the message.names
- Names of the variables to assign.values
- The values to set them to. Each element of the array is
the value for the corresponding element of 'names.MessageHandlerException
- if 'from' is not in the same context as
this mod.Copyright © 2017. All rights reserved.