|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.game.Commands
public class Commands
This is the command interpreter library for JSON command received from the game client. The server will search for commands in the general library (using Java reflection to examine this class), as well as a configuration-specified local “library” class for extensions specific to a given game.
This command processor is scanned for a method name matching the command name specified in the RPC call (JSON call) from the client. These commands can be invoked by any client.
Command names must start with do_, followed by the (typically javaCamelCased) command verb. The method signature must be exactly public static void do_ verb (Zone, JSONObject, User, Integer) .
Security is generally voluntary and must be enforced by individual methods.
Field Summary | |
---|---|
(package private) static org.json.JSONObject |
baseColors
cache for base colours palette |
(package private) static org.json.JSONObject |
extraColors
cache for extra colours palette |
Constructor Summary | |
---|---|
Commands()
|
Method Summary | |
---|---|
static void |
do_addFurniture(org.json.JSONObject jso,
AbstractUser u,
Room room)
Synonym for setFurniture |
static void |
do_addToList(org.json.JSONObject jso,
AbstractUser u,
Room room)
add a user to a buddy list or ignore list using the traditional (online-only, no notification engine) mechanism (using out of band methods). |
static void |
do_click(org.json.JSONObject jso,
AbstractUser u,
Room r)
Used by the client to report a mouse click. |
static void |
do_createUserHouse(org.json.JSONObject jso,
AbstractUser u,
Room room)
Response from the first run screen for the user's house |
static void |
do_dofff(org.json.JSONObject jso,
AbstractUser u,
Room room)
Response with total avatar info from "wardrobe" |
static void |
do_don(org.json.JSONObject jso,
AbstractUser u,
Room room)
JSON object has the item slot number to be worn (clothes, patterns, pivitz) and optionally set the color (for patterns) |
void |
do_eavesdrop(org.json.JSONObject jso,
AbstractUser u,
Room room)
WRITEME: Document this method brpocock@star-hope.org |
static void |
do_echo(org.json.JSONObject jso,
AbstractUser u,
Room room)
Echoes back the supplied JSON (or ActionScript) object to the client. |
static void |
do_endEvent(org.json.JSONObject jso,
AbstractUser u,
Room room)
This method terminates an event (probably a minigame, but possibly a fountain) which was initiated by startEvent. |
static void |
do_finger(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get public info for a list of (other) users. |
static void |
do_gameAction(org.json.JSONObject jso,
AbstractUser u,
Room room)
WRITEME — basically similar to an do_sendOutOfBandMessage(JSONObject, AbstractUser, Room)
but specifically something to do with a game |
static void |
do_getAvatars(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get avatar data for a list of (other) users. |
static void |
do_getColorPalettes(org.json.JSONObject jso,
AbstractUser u,
Room room)
Deprecated. This routine appears to be unused by anyone. If this is not true, please comment to BRPocock@Star-Hope.org or it will be removed without replacement before Appius 1.2 |
void |
do_getConfig(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get a configuration key from the server's config.properties file, based upon a key name beginning with "client." — note that clients cannot read arbitrary server config file values for security purposes; e.g. |
static void |
do_getInventory(org.json.JSONObject jso,
AbstractUser u,
Room room)
get all inventory for an user — both active and inactive |
static void |
do_getInventoryByType(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get a subset of items from your own inventory |
static void |
do_getOnlineUsers(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get a list of users in a Zone, or in a Room. |
static void |
do_getRoomList(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get a list of all “well known” Rooms currently active/visible. |
static void |
do_getServerTime(org.json.JSONObject jso,
AbstractUser u,
Room room)
Send the server time to the client requesting it (for synchronization purposes) |
static org.json.JSONObject |
do_getSessionApple(org.json.JSONObject jso,
AbstractUser who,
Room where)
Initialise a session key for batch mode operations |
static org.json.JSONObject |
do_getStoreItemInfo(org.json.JSONObject jso,
AbstractUser u,
Room r)
WRITEME: Document this method brpocock@star-hope.org |
void |
do_getText(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get a text string from the server's message catalogue |
static void |
do_getUserLists(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get the user's buddy list and ignore list. |
static void |
do_getWallet(org.json.JSONObject jso,
AbstractUser u,
Room room)
WRITEME: Document this method brpocock@star-hope.org |
static void |
do_getZoneList(org.json.JSONObject jso,
AbstractUser u,
Room room)
Get a list of all Zones currently active/visible. |
static void |
do_give(org.json.JSONObject jso,
AbstractUser u,
Room room)
Give an item to another user |
static void |
do_go(org.json.JSONObject jso,
AbstractUser u,
Room room)
go to a place and/or perform a gesture |
static void |
do_initUserRoom(org.json.JSONObject jso,
AbstractUser u,
Room userCurrentRoomInZone)
Creates room named user/user's name/room — room is the room index number given in the JSON data as “room,” it will always be zero right now as all users have single-room houses. |
static void |
do_join(org.json.JSONObject jso,
AbstractUser u,
Room room)
Join a room. |
static void |
do_logout(org.json.JSONObject jso,
AbstractUser u,
Room room)
Log out of this game session (or zone) |
static void |
do_mailCustomerService(org.json.JSONObject jso,
AbstractUser u,
Room room)
send an eMail to customer service (feedback) |
static void |
do_peekAtInventory(org.json.JSONObject jso,
AbstractUser u,
Room room)
Handle looking at other user's inventories |
static void |
do_ping(org.json.JSONObject jso,
AbstractUser u,
Room room)
Send a “ping” to the server to get back a “pong.” This also updates the user's last-active timestamp, to prevent them from being idled offline. |
static void |
do_promptReply(org.json.JSONObject jso,
AbstractUser u,
Room room)
Server initiates prompt with: |
static void |
do_removeFromList(org.json.JSONObject jso,
AbstractUser u,
Room room)
Remove someone from a buddy list or ignore list. |
static void |
do_reportBug(org.json.JSONObject jso,
AbstractUser u,
Room room)
This method allows the client to “phone home” to report a bug. |
static void |
do_reportUser(org.json.JSONObject jso,
AbstractUser u,
Room room)
Report an user to the moderator(s) on duty for breaking a rule |
static void |
do_requestBuddy(org.json.JSONObject jso,
AbstractUser u,
Room room)
Request adding a user to your buddy list (mutual-add) using the new notification-based system |
void |
do_savePrefs(org.json.JSONObject jso,
AbstractUser u,
Room room)
Set persistent user preferences on the server, to be maintained between sessions. |
static void |
do_sendOutOfBandMessage(org.json.JSONObject jso,
AbstractUser u,
Room room)
Send an arbitrary JSON packet to another user, or all of the users in a room, out of the band of communications. |
static void |
do_serverTime(org.json.JSONObject jso,
AbstractUser u,
Room room)
Accept the client's notification of a server-time adjustment. |
static void |
do_setAvatarColor(org.json.JSONObject jso,
AbstractUser u,
Room room)
Set the avatar base and extra colours for the given user. |
static void |
do_setFurniture(org.json.JSONObject jso,
AbstractUser u,
Room room)
Set or change a furniture item. |
static void |
do_setRoomVar(org.json.JSONObject jso,
AbstractUser u,
Room room)
Set a room variable or set of room variables. |
static void |
do_setUserVar(org.json.JSONObject jso,
AbstractUser u,
Room room)
Set user variable(s) |
static void |
do_spawnZone(org.json.JSONObject jso,
AbstractUser u,
Room room)
Spawn an additional zone. |
static void |
do_speak(org.json.JSONObject jso,
AbstractUser u,
Room room)
Handle speech by the user. |
static void |
do_startEvent(org.json.JSONObject jso,
AbstractUser u,
Room room)
Attempt to begin an event. |
static void |
do_useEquipment(org.json.JSONObject jso,
AbstractUser u,
Room r)
WRITEME: Document this method brpocock@star-hope.org |
private static String |
getBuddySignature(AbstractUser u,
AbstractUser u2)
Create a fancy signature thing to validate buddy list requests |
private static void |
getInventoryByType(org.json.JSONObject jso,
AbstractUser caller,
AbstractUser owner,
Room room)
JSON object has the type of item from the strings in the config file. |
static String |
getRev()
Get the current Subversion level of this file |
private static Collection<InventoryItemType> |
getTypeSetFromString(String typeString)
WRITEME: Document this method brpocock@star-hope.org |
(package private) static String |
handleDice(String inSpeech)
Handle die rolls, coin tosses, and magic Rock-Paper-Scissors picker |
private static String |
nonObnoxious(String speech)
remove some of the more obnoxious punctuation abuses from a string |
private static void |
speak_atMessage(AbstractUser u,
Room room,
String speech)
WRITEME: document this method (brpocock@star-hope.org, Mar 11, 2010) |
private static String |
speak_filterResultToString(AbstractUser u,
FilterResult carlSays)
WRITEME: document this method (brpocock@star-hope.org, Mar 11, 2010) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final org.json.JSONObject baseColors
static final org.json.JSONObject extraColors
Constructor Detail |
---|
public Commands()
Method Detail |
---|
public static void do_addFurniture(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, NotFoundException
jso
- See
do_setFurniture(JSONObject, AbstractUser, Room)
u
- The user calling this methodroom
- The room in which this user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON form
NotFoundException
- if the furniture doesn't existdo_setFurniture(JSONObject, AbstractUser, Room)
public static void do_addToList(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- { buddy: (name) } or { ignore: (name) } or { buddy:
(name), confirm: (boolean), sign: (signature) }u
- The user calling this methodroom
- The room in which this user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_click(org.json.JSONObject jso, AbstractUser u, Room r) throws org.json.JSONException
Used by the client to report a mouse click. There are a couple of different cases that this would be called.
First: if the user clicks on a placed-item in a room, this method should be called with the following syntax:
{"c":"click", "d":{ "on": itemID, "x": x, "y": y, "with": mods } }
Note that the (x,y) values passed are relative to the origin point of the item; thus, if an item is placed at (200,200) and is clicked at (210,210), the coördinates reported should be (10,10).
Alternatively, if the user clicks anywhere on the screen , and has one of the modifier keys held down (e.g. Shift, Meta, Control/Command) (but not Control on MacOS, as that represents a button-3-click), then send a click event like this:
{ "c":"click", "d":{ "x": x, "y":y, "with":mods } }
Note the absence of the "on" attribute in the second form.
The mods string can contain any of the following symbols in any order, representing modifier keys that were held down when the user clicked on the item:
In the Flash MouseEvent object, you can create the "mods" with the following:
var mods:String = "";
if (ev.altKey) mods += "M";
if (ev.commandKey || ev.ctrlKey) mods += "^";
if (ev.shiftKey) mods += "S";
if (ev.type == ev.CLICK) mods += "1";
if (ev.type == ev.MIDDLE_CLICK) mods += "2";
if (ev.type == ev.RIGHT_CLICK) mods += "3";
if (ev.type == ev.MOUSE_WHEEL) {
if (ev.delta < 0) mods += "-";
if (ev.delta > 0) mods += "+";
}
if (Keyboard.numLock) mods += "N";
if (Keyboard.capsLock) mods += "C";
jso
- See above. Must contain x, y, and mods. "mods" may be
a null string. May contain "on" with an ItemID (e.g.
"item99"), in which case, x,y are relative to the
item's origin.u
- The user clickingr
- The room in which the click happened
org.json.JSONException
- JSON data malformedpublic static void do_createUserHouse(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
Response from the first run screen for the user's house
Either create the user's house and lot, or add a room to their house.
jso
- Data describing the user's lot { lot: lot-ID, house:
house-ID }, or adding a room, { index: roomIndex }u
- The user buying the lotroom
- The room in which the user is found — for
communications purposes, at least.
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_dofff(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
Response with total avatar info from "wardrobe"
jso
- ignoredu
- The user calling this methodroom
- The room in which this user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_don(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, NumberFormatException, DataException
JSON object has the item slot number to be worn (clothes, patterns, pivitz) and optionally set the color (for patterns)
Response with total avatar info from "wardrobe"
jso
- { slot : ### } or { slot: ###, color: CCC } — valid
formats defined in Colour.Colour(String)
u
- The user calling this methodroom
- The room in which this user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON form
DataException
- for bad colour
NumberFormatException
- for bad colour numeric partspublic static void do_echo(org.json.JSONObject jso, AbstractUser u, Room room)
Echoes back the supplied JSON (or ActionScript) object to the client. This method exists solely for testing purposes.
Sends response containing:
Note that the field name is literally “You said:”
jso
- Any JSON object, the contents of which will be
returned to the caller.u
- The user calling (to whom the response is sent)room
- The room in which the user calls us (ignored)public static void do_endEvent(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
This method terminates an event (probably a minigame, but possibly a fountain) which was initiated by startEvent.
For fountains, the score is ignored, and a random number from 1..100 is used as the effective score. Since fountains (should) have a 1:1 points:peanuts ratio, this will earn the player 1..100 peanuts randomly per fountain visit.
Response: JSON sent to user: { ended: event ID; peanuts: number of peanuts earned; highScores: array of scores, indexed by position on the high score list (1..24), each of which contains: { points: number of points scored by the high-scoring user; userName: the name of the user }, totalPeanuts: user's new total peanut balance }
Additionally, if this user earned a high score on this event, s/he will get the attribute in the top level of the response as "gotHighScore": with the value being the position number which was earned. For example, earning no high score omits the "gotHighScore" attribute altogether; earning the third highest score will return instead "gotHighScore" == 3.
jso
- JSON parameters. { moniker = the event's moniker;
eventID = the event ID to be ended; score = the earned
score, in points (not peanuts); status = one of "cxl"
to cancel an event (in which case, score should be 0),
or "cmp" to complete an event (score may be zero or
more). }u
- The calling userroom
- The room in which the user is found (for replies)
org.json.JSONException
- if something nasty happenspublic static void do_finger(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
Get public info for a list of (other) users.
Reply format:
{ from: avatars, status: true, avatars: { 0: { USER-INFO … }, … }
User public information is in the format of
AbstractUser.getPublicInfo()
jso
- JSON object, with (ignored) keys tied to values which
must be the names of users.u
- The calling user. The calling user's avatar data will
not be returned.room
- the (ignored) room in which the method is being
called
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_gameAction(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
WRITEME — basically similar to an
do_sendOutOfBandMessage(JSONObject, AbstractUser, Room)
but specifically something to do with a game
jso
- { "action": (verb), (other params...) }u
- The user calling this methodroom
- The room in which this user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_getAvatars(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- JSON object, with (ignored) keys tied to values which
must be the names of users. e.g. { 0: "someUser", 1:
"otherUser" }u
- The calling user. The calling user's avatar data will
not be returned.room
- the (ignored) room in which the method is being
called
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON form@Deprecated public static void do_getColorPalettes(org.json.JSONObject jso, AbstractUser u, Room room) throws SQLException, org.json.JSONException
returns palettes in "extraColors", "baseColors", "patternColors" in the JSON result object (from: "getColorPalettes")
XXX contains SQL
Note: Not used in Tootsville™ any more. The analogous palettes in Li'l Vampies and Empires of the Air are being replaced with algorithmic checks, so this routine may be removed before Appius 1.2.0 unless there is a reason to maintain it.
jso
- JSON parameters: ignoredu
- calling userroom
- calling user's room
SQLException
- if something squirrelly happens
org.json.JSONException
- if something squirrelly happenspublic static void do_getInventory(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
get all inventory for an user — both active and inactive
Returns a set of items as inv: { 0: { id: 123, isActive: boolean }, ... } — furniture with placement data will also have x, y, and facing vars. Other attributes are "from":"inventory", "type": matching the type of the question
jso
- { }u
- The user whose inventory to be searchedroom
- The room in which the user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_getInventoryByType(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
Get a subset of items from your own inventory
jso
- { type: TYPE-STRING } — see
getInventoryByType(JSONObject, AbstractUser, AbstractUser, Room)
for discussion of TYPE-STRING; or { type: TYPE-STRING,
withActive: BOOLEAN } to mask out active items;
optional { who: LOGIN-NAME } to look at someone else's
inventoryu
- The user whose inventory to be searched, who is the
caller of this routineroom
- The room in which the user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_getOnlineUsers(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, PrivilegeRequiredException, NotFoundException
jso
- The JSON data provided by the caller. If this contains
an attribute of "inRoom" with a room moniker, we'll
only return the users in that room. Otherwise, all
users in the Zone will be returned.u
- The caller's ID. Must have staff privileges.room
- The room from which the caller is making the
extension call: ignored.
org.json.JSONException
- if the JSON data can't be processed, in or
out.
PrivilegeRequiredException
- if the user doesn't have
STAFF_LEVEL_STAFF_MEMBER
NotFoundException
- if the room requested doesn't existpublic static void do_getRoomList(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- Ignoredu
- The user requesting the data.room
- Ignored
org.json.JSONException
- If something untoward happenspublic static void do_getServerTime(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
Send the server time to the client requesting it (for synchronization purposes)
Sends a JSON object with a single property, serverTime, with the current time in milliseconds (give or take transit time)
jso
- ignoredu
- The user requesting the timeroom
- The room in which the user is standing
org.json.JSONException
- If the JSON data can't be written outpublic static org.json.JSONObject do_getSessionApple(org.json.JSONObject jso, AbstractUser who, Room where) throws org.json.JSONException
jso
- ignoredwho
- unusedwhere
- unused
org.json.JSONException
- if the reply can't be encoded in JSON form
for some reason...public static org.json.JSONObject do_getStoreItemInfo(org.json.JSONObject jso, AbstractUser u, Room r) throws org.json.JSONException
jso
- JavaScript array-style object where the key names are
ignored, but the values are item ID'su
- WRITEMEr
- WRITEME
org.json.JSONException
- if things go very wrongly.public static void do_getUserLists(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
{ buddyList: { … } , ignoreList: { … } }
jso
- no parameters neededu
- The user whose buddy and ignore lists will be fetchedroom
- The user's current room (ignored)
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_getWallet(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
org.json.JSONException
- WRITEMEpublic static void do_getZoneList(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
AbstractZone.getZoneList_JSON(org.starhope.appius.user.AbstractUser)
)
jso
- Ignoredu
- The user requesting the data.room
- Ignored
org.json.JSONException
- If something untoward happenspublic static void do_give(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, AlreadyExistsException
XXX: notify the recipient using notifications (currently using a Message Box popup message)
jso
- { slot: SLOT-NUMBER, to: USER-LOGIN }u
- giverroom
- room of gift being given
org.json.JSONException
- if the JSON data is malformed
AlreadyExistsException
- if the event can't be started for
some reasonpublic static void do_go(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- { do: VERB (required) u
- the user doing somethingroom
- the room in which the user is standing
org.json.JSONException
- if the packet can't be decoded somehowpublic static void do_initUserRoom(org.json.JSONObject jso, AbstractUser u, Room userCurrentRoomInZone) throws org.json.JSONException
Creates room named user/user's name/room — room is the room index number given in the JSON data as “room,” it will always be zero right now as all users have single-room houses. This will populate all furniture-type items for that room onto a set of room variables owned by the user. The user calling this method must be the owner of the room. If the user has not visited his/her house before, this will return an asynchronous "make a new house" notification to do the "first run" screen, by sending a message of type { "from": "initUserRoom", "status": false, "err": "showFirstRun" }.
Success: responds with true, and "moniker": the room's moniker (user/WHOEVER/123)
If unneccessary, returns an error of "exists" meaning that the room is already existing
jso
- { room: (room-number), autoJoin: (boolean) }u
- The user whose house-room needs to be initializeduserCurrentRoomInZone
- The room in which the user is
actually standing right now
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_join(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
NOTE the inconsistency: the command is join, but the reply comes from roomJoin
jso
- { room: MONIKER } or { room: MONIKER, from: MONIKER }u
- the user joining the roomroom
- the user's prior room
org.json.JSONException
- if the packet can't be producedpublic static void do_logout(org.json.JSONObject jso, AbstractUser u, Room room)
Log out of this game session (or zone)
There's a bug in the Persephone client that causes it to explode if we log it out before it receives & processes the logout message. So, we wait for the expected lag time to expire and then throw 2 full seconds of wasted wait time after it, which had ought to be enough time
Note: in the future, this will be configured to be off by default. Tootsville™ servers will need to incorporate the configuration key value if Persephone 2 hasn't been fixed by that time.
jso
- no datau
- The user logging outroom
- The room in which the user was standingpublic static void do_mailCustomerService(org.json.JSONObject jso, AbstractUser u, Room room)
jso
- { subject: STRING, body: STRING }u
- the user sending the feedbackroom
- the room in which the user is standingpublic static void do_peekAtInventory(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, NotFoundException
jso
- {"who": the login name of the user of whom to get the
inventory }; optional "type": to filter by type. (see
getInventoryByType(JSONObject, AbstractUser, AbstractUser, Room)
for details)u
- The user requesting the inventoryroom
- The room in which the request occurs
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON form
NotFoundException
- Could not find a user with that namepublic static void do_ping(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- No parametersu
- The user sending the “ping”room
- The room in which the user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_promptReply(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
Server initiates prompt with:
{ "from" : "prompt", "id" : $ID, "label" : $LABEL, "label_en_US" : $LABEL, "title" : $TITLE, [ "attachUser" : $AVATAR_LABEL || "attachItem" : $ITEM_ID ] , "msg" : $TEXT, "replies" : { $TOKEN : { "label" : $BUTTON_LABEL, "label_en_US" : $BUTTON_LABEL, "type" : $BUTTON_TYPE }, [ … ] } }
Where:
The "replies" assoc-array is of arbitrary length ≥ 2, where the key to each item is a $TOKEN, again an arbitrary string without \0 to represent this response uniquely. This is not an user-visible string.
$BUTTON_LABEL = the text to display. In future, the client may want to special-case specific text to use icons or something: e.g. "OK" will always be sent as precisely "OK" in English locale.
$BUTTON_TYPE = the type of the button for theming purposes only. This is from the enumerated set [ "aff" | "neg" | "neu" ];
To simplify future i18n/l10n efforts, the $LABEL and $BUTTON_LABEL will always be sent twice. The user's current language version will be in the "label" properties. The versions of those strings in the "en_US" locale will always be in the "label_en_US" properties. For purposes of theming and such, the label_en_US properties should be considered; the "label" properties, however, should always be used in presentation to the end-user.
Example:
{ "from": "prompt", "status": "true", "id": "fountain/tootSquare/þ=?/x'deadbeef'", "label": "Fountain", "label_en_US": "Fountain", "title": "Make a Wish?", "msg": "Do you want to make a wish on the Toot Square fountain?", "replies": { "yes": { "label": "Make a Wish!", "label_en_US": "Make a Wish!", "type": "aff" }, "no": { "label": "Not now", "label_en_US": "Not now", "type": "neg" } } }
The client's response is a bit simpler:
{ "c": "promptReply", "d": { "id": $ID, "reply": $TOKEN } }
e.g.
{ "c":"promptReply", "d": { "id": "fountain/tootSquare/þ=?/x'deadbeef'", "reply": "yes" } }
As a special-case, for the reply only, the special $TOKEN of "close" should be sent if the user dismissed the dialog box with the close button.
I'd suggest that the GUI attach anonymous functions with the reply packets already constructed to the various dialog box controls at creation time, rather than trying to manage some queue of pending prompts.
To handle user expectations, it would be best to display the button in a "down" state until receiving the server's acknowledgement of the "promptReply" and disallow multiple-clicking in the window.
The server will respond with
{ "from": "promptReply", "status": "true", "id": $ID }
For debugging purposes, the server may reply with
{ "from": "promptReply", "status": "false", "err": $ERR }
Where $ERR will be a brief description of the problem. e.g. $ERR = "reply.notFound" might represent a reply button that was not a valid $TOKEN from the "prompt" command nor the special case "close". $ERR = "id.notFound" might represent a reply to a prompt that was not (recently) asked.
A prompt ID is not valid across sessions; pending prompts should be auto-closed on logout. Prompts can, however, remain active indefinitely, even across room joins.
Optional implementation: the server may cancel an outstanding prompt request by sending a packet with the following properties:
Client applications may choose to dismiss the prompt automatically upon receiving such a packet. Failure to do so is not an error, however, later attempting to reply to a canceled prompt will return status: false, err: id.notFound. Clients must accept a cancelation packet silently if they do not process it.
jso
- in the form { id: $ID, reply: $TOKEN }, as detailed
aboveu
- the user replying to a promptroom
- the room in which the user is standing (unimportant)
org.json.JSONException
- for really bad syntax errorspublic static void do_removeFromList(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- To remove a buddy: { buddy: (name) }; or to attend to
someone who had previously been ignored: { ignore:
(name) }u
- The user whose buddy list or ignore list will be updatedroom
- The room in which the user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_reportBug(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
The suggested usage is to include the exception itself as “cause,” the backtrace up to a maximum of 1KiB, a log backtrace up to its last 1KiB as “bug,” and as much machine-formatted system information as possible in the “info” object.
As many fields as possible, limit the contents to a reasonable length though…
Note that the keys listed are strings, so e.g.:
info ["navigator.language"] = navigator.language; info ["navigator.product"] = navigator.product;
ActionScript example:
var info:Object = { "flash.sys.ime": flash.system.System.ime, "flash.sys.totalMemory": flash.system.System.totalMemory, "flash.sys.useCodePage": flash.system.System.useCodePage }; // imperfect but close for ( var key in flash.system.Capabilities ) { info["flash.sysCap." + key] = flash.system.Capabilities[key]; }
var topWindow = window.parent; for (; topWindow.parent != topWindow; topWindow = topWindow.parent) ; info ["window.windowName"] = topWindow.name;
// ActionScript example function systemReport:Object () { return { "screen": { "height": flash.system.Capabilities.screenResolutionX, "width": flash.system.Capabilities.screenResolutionY, "availHeight": flash.display.Stage.fullScreenHeight, "availWidth": flash.display.Stage.fullScreenWidth, }, "flash": { "sys": { "totalMemory": flash.system.System.totalMemory, "ime": flash.system.System.ime, "useCodePage": flash.system.System.useCodePage, }, "sysCap": { "avHardwareDisable": flash.system.Capabilities.avHardwareDisable, "hasAccessibility": flash.system.Capabilities.hasAccessibility, "hasAudio": flash.system.Capabilities.hasAudio, "hasAudioEncoder": flash.system.Capabilities.hasAudioEncoder, "hasEmbeddedVideo": flash.system.Capabilities.hasEmbeddedVideo, "hasIME": flash.system.Capabilities.hasIME, "hasMP3": flash.system.Capabilities.hasMP3, "hasPrinting": flash.system.Capabilities.hasPrinting, "hasScreenBroadcast": flash.system.Capabilities.hasScreenBroadcast, "hasScreenPlayback": flash.system.Capabilities.hasScreenPlayback, "hasStreamingAudio": flash.system.Capabilities.hasStreamingAudio, "hasStreamingVideo": flash.system.Capabilities.hasStreamingVideo, "hasTLS": flash.system.Capabilities.hasTLS, "hasVideoEncoder": flash.system.Capabilities.hasVideoEncoder, "isDebugger": flash.system.Capabilities.isDebugger, "isEmbeddedInAcrobat": flash.system.Capabilities.isEmbeddedInAcrobat, "language": flash.system.Capabilities.language, "localFileReadDisable": flash.system.Capabilities.localFileReadDisable, "manufacturer": flash.system.Capabilities.manufacturer, "os": flash.system.Capabilities.os, "pixelAspectRatio": flash.system.Capabilities.pixelAspectRatio, "playerType": flash.system.Capabilities.playerType, "screenColor": flash.system.Capabilities.screenColor, "screenDPI": flash.system.Capabilities.screenDPI, "version": flash.system.Capabilities.version }, "displayState": ( flash.display.Stage.displayState == FULL_SCREEN_INTERACTIVE ? "fullScreen" : "window" ), "frameRate": flash.display.Stage.frameRate, "quality": flash.display.Stage.quality, "scaleMode": flash.display.Stage.scaleMode } }; }
jso
- Must contain a single string attribute named “bug.”
Should contain an attribute named “info” with system
information key-value pairs (see above). May also have
a subject of “cause” as a string.u
- The user reporting the bug.room
- The user's current room.
org.json.JSONException
- JSON encoding errorpublic static void do_reportUser(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- { userName = user to be reported }u
- The user who is reporting the other userroom
- The room in which the reporting user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_requestBuddy(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- { buddy: LOGIN }u
- user who is requesting the additionroom
- unused
org.json.JSONException
- if the data can't be interpretedpublic static void do_sendOutOfBandMessage(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
Send an arbitrary JSON packet to another user, or all of the users in a room, out of the band of communications. This is neither a public nor a private message in the chat context: just some additional data that is being provided.
{ sender:
sender, from: outOfBand, status: true, body: {JSON} }
Adds "roomTitle" to body if body contains "room" and title can be determined
Add “"sendRoomList": "true"” to give the user an updated room list as well. (Necessary for invitations to new rooms.)
for user houses, roomTitle will be like "BlackDaddyNerd's House"
jso
- To send to one user:
{ to: userName, body: {JSON} }
, or to
broadcast to the entire room:
{ toRoom: true, body:
{JSON} }
u
- The sender of the out-of-band-messageroom
- The room in which the sender is standing. Necessary
for the toRoom version of this method.
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON formpublic static void do_serverTime(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- { serverTime: LONG milliseconds since epoch }u
- The user respondingroom
- The room in which the user is standing
org.json.JSONException
- if the packet is malformedpublic static void do_setAvatarColor(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, SQLException
Set the avatar base and extra colours for the given user.
Colour numbers are given in X'RRGGBB' form as an integer — to
compute one from byte (0..255) RGB values, do
( red << 16 & green << 8 & blue )
jso
- { "base": (colour number), "extra": (colour number) }u
- The user whose avatar colours are being setroom
- The room in which the user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON form
SQLException
- if the palettes can't be loadedpublic static void do_setFurniture(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, NotFoundException
Set or change a furniture item. To add a structural item to the room, put item: 123 without anything else. To place furniture on the floor, also add attributes x, y, and facing.
To change furniture, replace item: with slot: (to avoid ambiguities about “which chair”)
To remove an item from the room, send { slot: 123, remove: true }
jso
- { slot: #, x: #, y: #, facing: $ } or
{ item: #, x: #,
y: #, facing: $ } or
{ slot: #, remove: true }u
- The user calling this methodroom
- The room in which this user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON form
NotFoundException
- if the furniture doesn't existpublic static void do_setRoomVar(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, PrivilegeRequiredException
jso
- key-value pair(s) for room variable(s) to be setu
- the user requesting the changeroom
- the room to which the variable(s) are associated
org.json.JSONException
- if the packet is malformed
PrivilegeRequiredException
- if a non-privileged user
attempts to set a room variable.public static void do_setUserVar(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
Set user variable(s)
Input: { key : value } (one or more)
jso
- user variable(s) to setu
- the user setting themroom
- the room in which the user is standing
org.json.JSONException
- if the JSO can't be decodedpublic static void do_spawnZone(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, PrivilegeRequiredException
jso
- JSON object, containing an associative array whose
values are zones to be spawnedu
- The caller responsibleroom
- Where is the caller?
org.json.JSONException
- if something goes awry
PrivilegeRequiredException
- if the user isn't a Developerpublic static void do_speak(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, NotFoundException
Handle speech by the user. XXX This should be calling
User.speak(Room, String)
to do the dirty work: but, in
fact, the reverse is currently true.
Speech is public to all users in a room.
Emotes are simply speech beginning with "/". A few are special-cased. WRITEME: which
Commands are speech beginning with "#"
jso
- { "speech": TEXT-TO-BE-SPOKEN }u
- The user speakingroom
- The room in which the speech occurs.
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON form
NotFoundException
- WRITEMEpublic static void do_startEvent(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException, SQLException
Attempt to begin an event. Might return an error. Uses
Quaestor
for the heavy lifting.
Note that for all fountains, use the magic moniker “fountain”
Calls back the user with either of:
do_endEvent(JSONObject ,AbstractUser , Room )
jso
- JSON payload from the caller. Data: moniker = event
moniker.u
- The caller = the user performing the eventroom
- The caller's room. For fountains, we'll use this
room's moniker to figure out which fountain is which
org.json.JSONException
- if JSON data can't be put into a response,
or gotten out of a command.
SQLException
- probably means that the moniker is bad, but
I'm not really doing much to validate it herepublic static void do_useEquipment(org.json.JSONObject jso, AbstractUser u, Room r) throws org.json.JSONException
jso
- { t: slot-type-char, x: target-x, y: target-y, z:
target-z, [ on: target-name ] }u
- WRITEMEr
- WRITEME
org.json.JSONException
- WRITEMEprivate static String getBuddySignature(AbstractUser u, AbstractUser u2)
u
- The user calling this methodu2
- The user with whom they want to be buddies
private static void getInventoryByType(org.json.JSONObject jso, AbstractUser caller, AbstractUser owner, Room room) throws org.json.JSONException
JSON object has the type of item from the strings in the config file.
OR, you can specify an item type by passing # plus its ID, or a string of them; e.g. for items of type 1, pass "#1," for items of types 2 or 3, pass "#2:3"
OR, you can specify a list of item type strings using '$' plus the string identifiers divided by ':', e.g. "$Pants:Shirts"
Returns a set of items as inv: { 0: { id: 123, isActive: boolean }, ... } — furniture with placement data will also have x, y, and facing vars. Other attributes are "from":"inventory", "type": matching the type of the question
You can also supply withActive: false to screen out active items.
{ from: inventory, for: USER-LOGIN, type: TYPE-STRING, inv: { #: { ITEM-INFO }, #: { ITEM-INFO } … } }
jso
- { type: TYPE-STRING } — see above for discussion of
TYPE-STRING; { withActive: false } to mask out active
itemscaller
- The caller of the routine, who is inquiring about
someone else's inventoryowner
- the user owning the inventoryroom
- The room in which the user is standing
org.json.JSONException
- Thrown if the data cannot be interpreted
from the JSON objects passed in, or conversely, if we
can't encode a response into a JSON for,public static String getRev()
private static Collection<InventoryItemType> getTypeSetFromString(String typeString)
typeString
- WRITEME
static String handleDice(String inSpeech)
inSpeech
- Speech before filtering
private static String nonObnoxious(String speech)
speech
- a string to be edited
private static void speak_atMessage(AbstractUser u, Room room, String speech)
u
- WRITEMEroom
- WRITEMEspeech
- WRITEMEprivate static String speak_filterResultToString(AbstractUser u, FilterResult carlSays)
u
- WRITEMEcarlSays
- WRITEME
public void do_eavesdrop(org.json.JSONObject jso, AbstractUser u, Room room)
jso
- WRITEMEu
- WRITEMEroom
- WRITEMEpublic void do_getConfig(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- WRITEMEu
- WRITEMEroom
- WRITEME
org.json.JSONException
- WRITEMEpublic void do_getText(org.json.JSONObject jso, AbstractUser u, Room room) throws org.json.JSONException
jso
- { for : KEY } or { for: KEY, default: FALLBACK-STRING
}u
- the user (whose language will be considered)room
- the room in which the user is standing (unimportant)
org.json.JSONException
- if the input or output won't JSON
encode/decode cleanlypublic void do_savePrefs(org.json.JSONObject jso, AbstractUser u, Room room)
Set persistent user preferences on the server, to be maintained between sessions. Changes to preferences are reflected to the user at login, and any time they're changed.
Preferences are stored in hierarchical form as string values. However, the full “dotted notation” of any preference key must not extend beyond 100 characters in length.
At present, all preferences are echoed to all clients using an user account. There is no filter.
Preference keys cannot be deleted; the closest equivalent is to set their values to "". Each savePrefs call will only overwrite prior calls with identical keys; keys not replaced will be left alone.
jso
- The preference keys to be saved.u
- The user whose preferences are being savedroom
- The user's current room
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |