org.starhope.appius.game
Class PreLoginCommands

java.lang.Object
  extended by org.starhope.appius.game.PreLoginCommands

public class PreLoginCommands
extends Object

Commands that can be executed using JSON calls before the user has sent a login packet; or when the user is in hte process of logging-in

Author:
brpocock@star-hope.org

Constructor Summary
PreLoginCommands()
           
 
Method Summary
static org.json.JSONObject do_batch(org.json.JSONObject jso, AbstractUser nil0, Room nil1)
          Handle a batch request
static org.json.JSONObject do_finger(org.json.JSONObject jso, AbstractUser u, Room room)
          Finger an user account to obtain basic public information about it
static org.json.JSONObject do_getApple(org.json.JSONObject jso, AbstractUser nil0, Room nil1)
          Get the apple to get into, or out of, $Eden
static org.json.JSONObject do_login(org.json.JSONObject jso, AbstractUser nil0, Room nil1)
          Handle a login request
private static ServerThread findMyself(org.json.JSONObject result)
          Find the AppiusClaudiusCaecus thread in which we're being called
static String getRev()
          Get the revision level of this file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreLoginCommands

public PreLoginCommands()
Method Detail

do_batch

public static org.json.JSONObject do_batch(org.json.JSONObject jso,
                                           AbstractUser nil0,
                                           Room nil1)
                                    throws org.json.JSONException
Handle a batch request

Parameters:
jso - { userName: NAME, zone: ZONE, room: ROOM, auth: $(sha1hex(pass + apple + sha1hex(d))), userName: LOGIN, d: { 0: { c: CMD, d: {} }, 1: ... } }
nil0 - unused
nil1 - unused
Returns:
Replies with { from: batch, r: {0: ..., 1: ..., ... } }
Throws:
org.json.JSONException - if the result JSO cannot be generated

do_finger

public static org.json.JSONObject do_finger(org.json.JSONObject jso,
                                            AbstractUser u,
                                            Room room)
                                     throws org.json.JSONException
Finger an user account to obtain basic public information about it

Parameters:
jso - The JSON parameters passed to the finger command. The only parameter interpreted is “id,” which must be the user ID number whose public information is to be returned.
u - unused
room - unused
Returns:
no return, but replies with user information: { "from": "finger", "status": "false", "msg": "user.notfound", "userID": ### } or GeneralUser.getPublicInfo()
Throws:
org.json.JSONException - if the result set can't be created

do_getApple

public static org.json.JSONObject do_getApple(org.json.JSONObject jso,
                                              AbstractUser nil0,
                                              Room nil1)
                                       throws org.json.JSONException
Get the apple to get into, or out of, $Eden

Parameters:
jso - ignored
nil0 - unused
nil1 - unused
Returns:
Replies with { from: getApple, apple: (OPAQUE-STRING) }
Throws:
org.json.JSONException - if the reply can't be encoded in JSON form for some reason...

do_login

public static org.json.JSONObject do_login(org.json.JSONObject jso,
                                           AbstractUser nil0,
                                           Room nil1)
                                    throws org.json.JSONException
Handle a login request

Parameters:
jso - { userName: LOGIN, password: PASS, zone: ZONE }
nil0 - unused
nil1 - unused
Returns:
Replies with { from: login ... }
Throws:
org.json.JSONException - if the result JSO cannot be generated

findMyself

private static ServerThread findMyself(org.json.JSONObject result)
                                throws org.json.JSONException
Find the AppiusClaudiusCaecus thread in which we're being called

Parameters:
result - a JSON result object into which errors can be stored
Returns:
the AppiusClaudiusCaecus thread, or null if we were called from some other thread
Throws:
org.json.JSONException - if the error packet can't be generated

getRev

public static String getRev()
Get the revision level of this file

Returns:
the revision level of this file in Subversion