|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.starhope.appius.game.AppiusClaudiusCaecus
public class AppiusClaudiusCaecus
Appius Claudius Caecus is a game server application framework. Extensible using Java classes loaded from its extensive library of configurable options, Appius provides a network server for real-time data exchange.
Originally titled “Braque,” this application was developed for use with the videogame (work in progress) “Sideres.” It was designed to operate with a messaging protocol called “Cubist,” which has since been defined in terms of a simple JSON + \0 wire protocol.
Since that time, I have repurposed the game engine for use with Tootsville™ (http://www.Tootsville.com/) and set up a new series of communications supports designed to be compatible with the ActionScript 3 libraries for Smart Fox Server Pro.
The server should still be able to operate on its own with minimal changes. Most of the Tootsville-specific code has been isolated into the com.tootsville.* package, but replacement code for some methods might be needed to create a stand-alone game. Also, some default configuration values are Tootsville-oriented.
This class in general operates as both the main game thread and socket listener — in the static methods and variables — and the client-connected user thread — in the instance methods and variables. The “metronome” timer thread also runs using the static methods of this class.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private static PreparedStatement |
blatherStatement
Prepared statement used to inject log entries into the log |
private static long |
bootTime
The time at which the server was started |
private boolean |
busyState
While we are processing a transaction for the user (during command processing), this flag is brought high to block idle timeouts due to overlong transactions |
(package private) static Charon |
charon
Global reaper thread to reap zombies |
private float |
clientProtocolLanguage
The language variant that the client is speaking. |
private boolean |
debug
Boolean flag indicating whether the server is in debugging mode or not. |
static int |
DELAY_MS
The delay before the first run of the NPC manager task. |
private ConcurrentLinkedQueue<AppiusDatagram> |
futureDatagrams
The queue of all datagrams pending for this user. |
private static int |
highWaterUsers
The most users who have been online since the server started |
private long |
idleWarned
At what time was the user warned about being idle for too long? |
private BufferedReader |
in
The buffered input stream from the user. |
private boolean |
isDone
This indicates whether the thread has voluntarily decided to exit, e.g. |
(package private) static SimpleDateFormat |
isoDate
The date format used for system messages. |
private static Connection |
journalDB
The connection to the journal database, used by blather |
private static boolean |
keepListening
If this ever transitions to “false,” stop listening for new connections. |
private boolean |
keepRunning
This variable controls the main loop of the server thread. |
private static boolean |
knowWhyJournalDBOut
If the journaling database goes offline, this variable will keep from getting a flood of bug reports. |
private long |
lastInputTime
The time at which we last received input from the remote user. |
private static long |
lastMetronomeTick
The time at which the global metronome thread last ticked. |
private String |
letsPlayWithFlash
This is a crazy XML looking string that we have to pump out to make the Flash plug-in happy. |
private boolean |
loggedIn
If the user has been logged in, this flag will be true |
(package private) static Zone |
loginZone
Users logging in are directed first the this landing zone, and then choose a Zone server to which they wish to connect (if multiple Zones have been established). |
private int |
maxInputSize
The maximum number of characters (or is it bytes? I'm unclear on my own implementation there!) that can be accepted from the client in a single packet |
(package private) static Timer |
metronome
The timer driving the global metronome. |
private static ConcurrentSkipListSet<AcceptsMetronomeTicks> |
metronomeListeners
Collection of arbitrary objects who wish to receive Metronome ticks |
(package private) static Thread |
metronomeThread
The global metronome thread. |
private static String |
motd
Message of the day |
private User |
myUser
The user account that is logged in on this thread |
(package private) PrintWriter |
out
The output stream connected to the client |
private static int |
port
The listening port for the server |
private int |
preloginCountdown
The number of prelogin commands that can be accepted before the user is dropped for failing to log in |
private String |
randomKey
random key used for SHA1 sum in login |
private static long |
serialVersionUID
The version of the serialized form of this class. |
private static ConcurrentHashMap<String,AppiusClaudiusCaecus> |
serverThreads
All live server threads |
private Socket |
socket
The socket connected to the client session |
private static boolean |
started
A global boolean flag to indicate that the server has started up successfully |
private int |
state
The state of the conversation that we are having with the client |
private static long |
tGameStatePump
Time at which the Game State pump last ran |
private long |
tLastNudge
Time at which users were last nudged to check their online status |
private static long |
tStats
Time at which the server statistics were last “reportBug” mailed |
private static int |
TWENTY_ONE_YEARS_MSEC
The number of milliseconds in 21 years. |
private Zone |
zone
The Zone in which this thread is connecting |
private static ConcurrentHashMap<String,Zone> |
zones
All zones active on this server |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
AppiusClaudiusCaecus(Socket newSocket,
Zone newZone)
Create a new thread connected to a given client, in a certain zone. |
|
AppiusClaudiusCaecus(String string)
Just for uncaught exception handler faux-thread |
Method Summary | |
---|---|
static void |
add(AcceptsMetronomeTicks listener)
Add a thread to the Metronome tick event schedule without that thread being |
static void |
add(Zone zone)
Add a Zone to the global Zones list |
static void |
addZone(String zoneName,
Zone zone)
Deprecated. |
private void |
areYouThere()
Send a packet to the user to see if they're still there |
static void |
blather(String message)
Print a debugging message at low urgency, from a random place |
static void |
blather(String user,
String room,
String address,
String message,
boolean urgent)
Write out a log message to the log file and/or database |
static void |
bugDuplex(String subject,
String message)
Write out an error message to the log file and/or mail, as appropriate |
void |
close()
Close the socket, terminate the connection |
void |
commandJSON(String cmd,
org.json.JSONObject jso,
Class<?> klass)
Process a command from a JSON source |
int |
compareTo(AppiusClaudiusCaecus other)
Compare two AppiusClaudiusCaecus server threads |
static void |
configUpdated()
|
void |
disconnectDuplicate()
Disconnect *this* user, with a notification that they have logged in from someplace else. |
private void |
dropSocketConnection()
Drop the I/O socket for this user. |
private void |
end()
Indicate that this thread should cease to breathe. |
void |
enterZone(String zoneName)
Enter into a Zone (set the local zone indicator) |
void |
enterZone(Zone whichZone)
Enter into a Zone (set the local zone indicator) |
boolean |
equals(AppiusClaudiusCaecus other)
This is an overriding method. |
boolean |
equals(Object other)
This is an overriding method. |
void |
failLogin()
This method is called when login fails. |
static Error |
fatalBug(Exception e)
The exception passed in will be reported, as per reportBug, and then re-thrown as an Error, killing the process responsible |
static Error |
fatalBug(String string)
Report a bug, and throw a fatal Error. |
static Error |
fatalBug(String string,
Throwable t)
Report a bug, and throw a fatal Error. |
private void |
genRandomKey()
Generate a new random key, avoiding characters that won't work with Smart Fox Server clients |
private static int |
getAccurateHeadcount()
Get the accurate number of users in all zones. |
static Collection<AbstractUser> |
getAllUsers()
Get a collection of all users in all zones. |
static LinkedList<AbstractZone> |
getAllZones()
|
String |
getApple(String pass)
Get the “apple” (CHAP authentication string SHA1 digest encoded in hex) for the login system |
static long |
getBootTime()
Get the server start time |
(package private) static Charon |
getCharon()
Get the Charon reaper thread |
static int |
getHighWaterUsers()
Get the high-water mark count of users |
String |
getIpAddress()
Deprecated. Smart Fox Server Pro misspelling of getIPAddress() |
String |
getIPAddress()
|
static long |
getLastMetronomeTick()
|
static String |
getMOTD()
|
String |
getRandomKey()
|
static String |
getRev()
Get the revision number of this file |
static String |
getServerHostname()
Get the hostname on which the server process is running |
static int |
getServerPort()
The server (TCP) port number |
float |
getSFSVersion()
|
private Socket |
getSocket()
Get the socket connection to the client |
private static String |
getStackTrace(Throwable throwable)
This extracts a stack backtrace from a Throwable into a string format for a bug report. |
private static String |
getStackTrace(Throwable throwable,
String prefix)
This extracts a stack backtrace from a Throwable into a string format for a bug report. |
static int |
getThreadCount()
Returns the number of server threads running. |
User |
getUser()
|
Zone |
getZone()
Get the zone in which this client is acting |
static Zone |
getZone(String zoneName)
Find a Zone object for a given zone name |
private String |
grabInput()
Get input from the client stream |
int |
hashCode()
This is an overriding method. |
boolean |
isDebug()
Determine whether the server is in debugging mode |
boolean |
isLoggedIn()
|
protected void |
kickDuplicates(User user,
String nick)
Kick offline any duplicates of the given user as s/he logs in |
protected void |
kickDuplicates(User user,
String nick,
String password)
Deprecated. use kickDuplicates(User, String) |
private static void |
listenForever()
Listen for incoming connections, and sit here until we get one. |
static void |
logEvent(String verb,
String zoneName,
String userName,
String targetName,
HashMap<String,String> details)
Record an event to the journal |
boolean |
logIn(Zone z,
String bigNick,
String password)
Process a login request from the user |
static void |
main(String[] argv)
This is the main routine to run Appius as a stand-alone server. |
void |
migrate(String hostName,
int portNumber,
String zoneName)
Order this user to migrate to another Appius Claudius Caecus server. |
static void |
migrateAll(String otherHost,
int otherPort)
Migrate all users to another host. |
String |
processInput(String theInput)
Process and dispatch input from the client. |
private String |
processJSONInput(String theInput)
Process a JSON string from the client |
private String |
processJSONLogin(String theInput)
Process a JSON command sequence from the client |
private String |
processJSONPreLogin(String theInput)
Process a prelogin JSON command |
private String |
processPreLogin(String theInput)
Process a prelogin input sequence |
private String |
processXMLInput(String theInput)
|
static void |
remove(AcceptsMetronomeTicks listener)
Remove a metronome listener |
static void |
remove(Zone whichZone)
Remove a zone from the server |
static void |
reportBug(String string)
Report a bug. |
static void |
reportBug(String reason,
Throwable throwable)
Report a bug to the automatic bug-tracking systems. |
static void |
reportBug(Throwable e)
|
static void |
reportClientBug(String string)
Report a bug from the client application. |
static void |
reportClientBug(String string,
AppiusClaudiusCaecus thread)
Report a bug from the client application. |
static void |
restart()
This should restart the server, but it doesn't. |
static void |
restartMetronome()
Attempt to restart the global metronome — this probably won't work as currently implemented (?) |
void |
run()
Run the server thread connected to a client |
void |
sendAdminDisconnect(String message,
String title,
String label,
String disconnectCause)
Send a disconnection message, and drop the user on the next client cycle. |
void |
sendAdminMessage(String message,
boolean remote)
Send an administrative message to the user. |
void |
sendAdminMessage(String message,
String title,
String hatLabel,
boolean remote)
Send an administrative message. |
private void |
sendDeferredDatagrams()
Send all deferred (future) datagrams pending in the queue |
void |
sendError_RAW(String errorSource,
String message)
Send a raw error message back to the client as a JSON response |
private boolean |
sendFutureDatagrams()
Send any future datagrams that are pending for this user |
void |
sendGameActionMessage(AbstractUser sender,
org.json.JSONObject data)
Send a game action event message to the client |
protected void |
sendLoginPacket(String zoneName,
String nick,
String password)
Send the bucketfuls of information that we force-feed the client at login... |
protected void |
sendLogKO()
Send a login failure message to the client, using the default (generic) message |
protected void |
sendLogKO(String messageText)
Send a “KO” message to the client, informing them that they are not permitted to log in. |
void |
sendPrivateMessage(AbstractUser from,
String message)
Send a private (“whisper”) message to the user |
void |
sendPublicMessage(AbstractUser from,
String message)
Send a public message |
void |
sendRawMessage(String reply,
boolean remote)
|
private void |
sendRawMessageLater(String reply)
Send a message to the user in future |
void |
sendResponse(org.json.JSONObject result)
Send a response as a future (deferred remote) datagram without a room specified |
void |
sendResponse(org.json.JSONObject result,
int room,
boolean remote)
Send a response to the client in JSON form. |
void |
sendResponse(org.json.JSONObject result,
Integer room)
Send a response as a future (deferred remote) datagram |
void |
sendResponse(org.json.JSONObject result,
Integer room,
AbstractUser u)
|
void |
sendResponseRemote(org.json.JSONObject result,
Integer room,
AbstractUser u)
Deprecated. use sendResponse(JSONObject, Integer) |
void |
sendRoomEnteredByUser(AbstractRoom room,
AbstractUser user)
Send notification that an user has joined a room |
void |
sendRoomList()
Send the user a room list for their current zone |
void |
sendRoomList(AbstractZone forZone,
boolean remote)
Send the user a room list for an arbitrary zone |
void |
sendRoomPartedBy(AbstractRoom room,
AbstractUser user)
Send a notification that an user has departed from a room |
void |
sendRoomUserCount(AbstractRoom room)
Send the user count for the given room |
void |
sendRoomVar(int roomNum,
String varName,
String varValue)
|
void |
sendSuccessReply(String source,
org.json.JSONObject resultIn,
AbstractUser u,
int room)
Send a JSON success packet back to the client |
void |
sendUserPart(AbstractUser user,
AbstractRoom room)
Deprecated. use #sendRoomPartedBy(Room, AbstractUser) |
void |
sendUserVariable(User user,
String varName,
String varValue)
Send an update to an user variable |
void |
setBusyState(boolean b)
|
void |
setDebug(boolean newDebug)
Set the server's debugging mode on (true) or off (false) |
void |
setLastInputTime(long thatTime)
|
void |
setLoggedIn(boolean amILoggedInNow)
|
static void |
setMOTD(String string)
TODO: document this method (brpocock, Jan 5, 2010) |
void |
setSFSVersion(float smartFoxServerCommProtocolVersion)
|
private void |
setup()
Set up this thread to execute |
static void |
startMetronome()
Start the global metronome to ticking |
private static void |
startTicking(AppiusClaudiusCaecus thread)
Register an object (usually a server thread) who wishes to begin accepting metronome ticks. |
static void |
stopMetronome()
|
private static void |
stopTicking(AcceptsMetronomeTicks thread)
Stop sending metronome ticks to a particular object. |
static String |
stringify(StackTraceElement[] stackTrace)
Create a pure string version of a stack backtrace |
static String |
stringify(Throwable e)
|
void |
tattle(String message)
tattle a non-urgent message |
void |
tattle(String tattle,
boolean urgent)
Print a log entry to STDERR with a great deal of identifiable detail |
private boolean |
tick_checkIdleKick(long tIdle)
Check whether the user has been idle for too long, and kick them offline if so |
private boolean |
tick_checkIdleWarnTime(long tIdle)
Check how long the user has been idle, and send a warning if the time idle has exceeded a limit |
static void |
tick()
The main metronome single-threaded tick |
void |
tick(long t,
long dT)
Propagate a metronome tick |
String |
toString()
This returns a plethora of debugging-useful information about this particular server thread. |
static void |
traceThis()
Force a stack backtrace without an exception being thrown. |
static void |
traceThis(String string)
Force a stack backtrace without an exception being thrown. |
void |
uncaughtException(Thread t,
Throwable e)
This is an overriding method. |
static void |
updateHighWaterMark()
Update the high water mark, if necessary |
private String |
userDebug(String string)
Create a message string informing the user that an error has occurred, and instructing them to contact Customer Service. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.starhope.appius.util.HasName |
---|
getName |
Field Detail |
---|
private static PreparedStatement blatherStatement
private static final long bootTime
static final Charon charon
public static final int DELAY_MS
private static int highWaterUsers
static final SimpleDateFormat isoDate
private static Connection journalDB
private static boolean keepListening
private static boolean knowWhyJournalDBOut
private static long lastMetronomeTick
static Zone loginZone
static Timer metronome
private static ConcurrentSkipListSet<AcceptsMetronomeTicks> metronomeListeners
static Thread metronomeThread
private static String motd
private static int port
private static final long serialVersionUID
private static ConcurrentHashMap<String,AppiusClaudiusCaecus> serverThreads
private static boolean started
private static long tGameStatePump
private static long tStats
private static final int TWENTY_ONE_YEARS_MSEC
private static ConcurrentHashMap<String,Zone> zones
private boolean busyState
private float clientProtocolLanguage
private boolean debug
private final ConcurrentLinkedQueue<AppiusDatagram> futureDatagrams
private long idleWarned
private BufferedReader in
private boolean isDone
private boolean keepRunning
private long lastInputTime
private final String letsPlayWithFlash
private boolean loggedIn
private final int maxInputSize
private User myUser
PrintWriter out
private int preloginCountdown
private transient String randomKey
private Socket socket
private int state
private long tLastNudge
private Zone zone
Constructor Detail |
---|
public AppiusClaudiusCaecus(Socket newSocket, Zone newZone)
newSocket
- The socket connected to the clientnewZone
- The login zone into which the client is connectedpublic AppiusClaudiusCaecus(String string)
string
- thread nameMethod Detail |
---|
public static void add(AcceptsMetronomeTicks listener)
listener
- The listener who wishes to receive Metronome
ticks.public static void add(Zone zone)
zone
- the Zone to be added@Deprecated public static void addZone(String zoneName, Zone zone)
zoneName
- The zone's namezone
- The Zone objectpublic static void blather(String message)
message
- The messagepublic static void blather(String user, String room, String address, String message, boolean urgent)
user
- The user name and ID responsibleroom
- The room and zone in which the action occurredaddress
- The user's remote socket's IP address and port
numbermessage
- The event which occurredurgent
- Urgent messages are written even when debugging is
disabledpublic static void bugDuplex(String subject, String message)
subject
- The subjectmessage
- The error messagepublic static void configUpdated()
public static Error fatalBug(Exception e)
e
- An exception to report
Error
- (based upon the exception) every time. Since the
Error is also thrown, it's never actually received by
the caller, but it makes the compiler happy to write
it into a throw clause, so it realizes that the flow
will not continue.public static Error fatalBug(String string)
string
- The error to report
public static Error fatalBug(String string, Throwable t)
string
- A description of the error to reportt
- An exception to escalate to the Error
private static int getAccurateHeadcount()
public static Collection<AbstractUser> getAllUsers()
public static LinkedList<AbstractZone> getAllZones()
public static long getBootTime()
static Charon getCharon()
Charon
reaper thread
public static int getHighWaterUsers()
public static long getLastMetronomeTick()
public static String getMOTD()
public static String getRev()
public static String getServerHostname()
public static int getServerPort()
private static String getStackTrace(Throwable throwable)
This extracts a stack backtrace from a Throwable into a string format for a bug report. Each line is tagged with a leading "/#" string, followed by a space, the stack backtrace element, and a newline.
This is the same as calling
getStackTrace(Throwable, String)
with a prefix of "\n/#"
throwable
- The Throwable containing stack backtrace data
private static String getStackTrace(Throwable throwable, String prefix)
throwable
- A Throwable
from which to extract a
stack traceprefix
- The string with which to separate lines of the
trace.
public static int getThreadCount()
public static Zone getZone(String zoneName)
zoneName
- The name of the zone to be found
private static void listenForever()
Listen for incoming connections, and sit here until we get one.
If keepListening is altered from elsewhere, then the loop will restart; probably because the port number has been changed.
public static void logEvent(String verb, String zoneName, String userName, String targetName, HashMap<String,String> details)
verb
- The verb describing the eventzoneName
- The zone in which it occurreduserName
- The user causing the actiontargetName
- The target of the action, if anydetails
- Additional detailspublic static void main(String[] argv) throws IOException
argv
- Any command-line arguments
IOException
- if there's an I/O exceptionpublic static void migrateAll(String otherHost, int otherPort)
Migrate all users to another host. They will attempt to connect to identical zones as the ones which are currently active.
This is a low-level function and does nothing to ensure that the given zone actually exists on the other server
otherHost
- the other host to which users should migrateotherPort
- the other host's listening port to which users
should migratepublic static void remove(AcceptsMetronomeTicks listener)
listener
- The listener to deregisterpublic static void remove(Zone whichZone)
whichZone
- The zone to be removedpublic static void reportBug(String string)
Report a bug.
This is used to catch either ‘impossible things’ or things that are so bad that immediate programmer intervention is needed.
Bug reports should eventually be funneled into the bug-tracking system or similar automatically, and forwarded to the systems programmers via eMail and SMS.
string
- Bug reportpublic static void reportBug(String reason, Throwable throwable)
reason
- The reason this is a bug, if known.throwable
- The "impossible" exception.public static void reportBug(Throwable e)
e
- An exception to reportpublic static void reportClientBug(String string)
string
- The client application's bugpublic static void reportClientBug(String string, AppiusClaudiusCaecus thread)
string
- The client application's bugthread
- The associated server thread, whose information
will be prepended, if present. (null is a valid
answer, for backward compatibility)public static void restart()
public static void restartMetronome()
public static void setMOTD(String string)
string
- new message of the daypublic static void startMetronome()
private static void startTicking(AppiusClaudiusCaecus thread)
thread
- the thread who wants to accept ticks nowpublic static void stopMetronome()
private static void stopTicking(AcceptsMetronomeTicks thread)
Thread
as well, also sends the
Thread
an Thread.interrupt()
. If it's an instance
of AppiusClaudiusCaecus
, it will first call the thread's
end()
method.
thread
- the object who doesn't want to get any more tickspublic static String stringify(StackTraceElement[] stackTrace)
stackTrace
- An array of StackTraceElements:s
public static String stringify(Throwable e)
e
- A Throwable to be stringified into a backtrace
public static void tick()
public static void traceThis()
public static void traceThis(String string)
string
- A string to be used as a label on the tracepublic static void updateHighWaterMark()
private void areYouThere() throws UserDeadException
UserDeadException
- if the user is disconnectedpublic void close()
public void commandJSON(String cmd, org.json.JSONObject jso, Class<?> klass)
cmd
- The command to be processedjso
- The JSON data object to be passed into the relevant
commandklass
- The dispatcher class responsible for handling this
commandpublic int compareTo(AppiusClaudiusCaecus other)
AppiusClaudiusCaecus
server threads
compareTo
in interface Comparable<AppiusClaudiusCaecus>
other
- another server thread
Comparable.compareTo(java.lang.Object)
public void disconnectDuplicate()
private void dropSocketConnection()
private void end()
public void enterZone(String zoneName)
zoneName
- the name of the Zonepublic void enterZone(Zone whichZone)
whichZone
- The zone being enteredpublic boolean equals(AppiusClaudiusCaecus other)
other
- the other thread against which to compare
Object.equals(java.lang.Object)
public boolean equals(Object other)
equals
in class Object
Object.equals(java.lang.Object)
public void failLogin()
private void genRandomKey()
public String getApple(String pass)
pass
- The plaintext password to be used
@Deprecated public String getIpAddress()
getIPAddress()
public String getIPAddress()
public String getRandomKey()
public float getSFSVersion()
private Socket getSocket()
public User getUser()
public Zone getZone()
private String grabInput() throws UserDeadException
UserDeadException
- if the user disconnectspublic int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean isDebug()
public boolean isLoggedIn()
protected void kickDuplicates(User user, String nick)
user
- The user logging in (whose duplicates should be
disconnected)nick
- The user's nickname (login name)@Deprecated protected void kickDuplicates(User user, String nick, String password)
kickDuplicates(User, String)
user
- The user logging in (whose duplicates should be
disconnected)nick
- The user's nickname (login name)password
- The user's password (ignored)public boolean logIn(Zone z, String bigNick, String password)
z
- The zone into which the user is trying to log inbigNick
- The user's requested nickname (attempted user
name)password
- This is a bit of a misnomer. We actually are
checking for the secret key (CHAP cookie) for the
current channel, to which has been appended the user's
actual password, as presented as a hex-coded SHA1
digest. (In brief: pseudocode of sha1( cookie +
password ).toHex )
public void migrate(String hostName, int portNumber, String zoneName)
hostName
- The alternate server's public host name or IP
address stringportNumber
- The listening port on the alternate serverzoneName
- The zone name to which the user should connectpublic String processInput(String theInput)
theInput
- The input packet from the client
private String processJSONInput(String theInput)
theInput
- The JSON string containing the command and data
private String processJSONLogin(String theInput)
theInput
- the JSON data in string form
private String processJSONPreLogin(String theInput)
theInput
- The input string, which must contain a
properly-formatted JSON command sequence
private String processPreLogin(String theInput) throws UserDeadException
theInput
- the prelogin input sequence
UserDeadException
- if the user disconnectsprivate String processXMLInput(String theInput)
theInput
- The input stream, expected to be in Smart Fox
Server Pro XML format
public void run()
run
in interface Runnable
run
in class Thread
Thread.run()
public void sendAdminDisconnect(String message, String title, String label, String disconnectCause)
message
- User-visible message explaining the disconnectiontitle
- Title to display in message boxlabel
- Label to display in corner of message boxdisconnectCause
- Cause code to return to client application
giving general cause for disconnection; e.g. "kick" or
"ban" usuallypublic void sendAdminMessage(String message, boolean remote) throws UserDeadException
message
- administrative message to sendremote
- if true, this is being written to another user
UserDeadException
- if the user has been disconnectedsendAdminMessage(String, String, String, boolean)
public void sendAdminMessage(String message, String title, String hatLabel, boolean remote) throws UserDeadException
message
- The actual message texttitle
- The title, which displays in the same font above the
message, but does not scrollhatLabel
- A short label which identifies the general source
of the message, for dialog box decorationremote
- Whether to send this message remotely (true =
deferred delivery) or immediately (false)
UserDeadException
- if the user isn't there to receive the
messageprivate void sendDeferredDatagrams() throws UserDeadException
UserDeadException
- if the user has disconnectedpublic void sendError_RAW(String errorSource, String message)
sendError_RAW
in interface org.starhope.util.types.CanProcessCommands
errorSource
- The method that is the source of the errormessage
- The error message to be returnedprivate boolean sendFutureDatagrams()
public void sendGameActionMessage(AbstractUser sender, org.json.JSONObject data) throws org.json.JSONException, UserDeadException
sender
- The user sending the game actiondata
- Arbitrary data associated with the game action
org.json.JSONException
- if the data can't be represented as JSON
UserDeadException
- if the user has been disconnectedprotected void sendLoginPacket(String zoneName, String nick, String password)
zoneName
- The name of the zone into which the user has
logged innick
- The user's nicknamepassword
- The user's password (SHA1 encoded with the local
random key)protected void sendLogKO()
protected void sendLogKO(String messageText)
messageText
- The user-visible message given to the userpublic void sendPrivateMessage(AbstractUser from, String message) throws UserDeadException
from
- The user sending the messagemessage
- The message being whispered
UserDeadException
- if the user has been disconnectedpublic void sendPublicMessage(AbstractUser from, String message) throws UserDeadException
from
- sender of the message (speaker)message
- The public message
UserDeadException
- if the user has been disconnectedpublic void sendRawMessage(String reply, boolean remote) throws UserDeadException
reply
- The string to be transmitted to another userremote
- True, if being written to another user
UserDeadException
- if the user has been disconnectedprivate void sendRawMessageLater(String reply) throws UserDeadException
reply
- The message to be sent in future
UserDeadException
- if the user is already gonepublic void sendResponse(org.json.JSONObject result) throws UserDeadException
sendResponse
in interface org.starhope.util.types.CanProcessCommands
result
- WRITEME
UserDeadException
- if the user disconnectssendResponse(JSONObject, int, boolean)
,
CanProcessCommands.sendResponse(org.json.JSONObject)
public void sendResponse(org.json.JSONObject result, int room, boolean remote) throws UserDeadException
result
- the JSON object to be returned to the clientroom
- The room number from which the response is being
sent.remote
- Whether to send the message as a remote (deferred
future datagram) message
UserDeadException
- if the user has been disconnectedpublic void sendResponse(org.json.JSONObject result, Integer room) throws UserDeadException
result
- the JSON result object to be sent (“extension
response”)room
- The room in which the event occurred.
UserDeadException
- if the user has disconnectedsendResponse(JSONObject, int, boolean)
public void sendResponse(org.json.JSONObject result, Integer room, AbstractUser u) throws UserDeadException
result
- the JSON result object to be sent (“extension
response”)room
- The room in which the event occurred.u
- The user to whom the message is being sent
UserDeadException
- if the user has disconnected@Deprecated public void sendResponseRemote(org.json.JSONObject result, Integer room, AbstractUser u) throws UserDeadException
sendResponse(JSONObject, Integer)
result
- the JSON object to send to the clientroom
- the room number in which the event occurredu
- ignored…
UserDeadException
- if the user has already disconnectedpublic void sendRoomEnteredByUser(AbstractRoom room, AbstractUser user) throws UserDeadException
room
- the room that has been joined by an useruser
- the user joining the room
UserDeadException
- if the user has been disconnectedpublic void sendRoomList() throws UserDeadException
UserDeadException
- if the user has been disconnectedpublic void sendRoomList(AbstractZone forZone, boolean remote) throws UserDeadException
forZone
- The zone for which the user will receive a room
listremote
- If true, writing to a remote user
UserDeadException
- if the user has been disconnectedpublic void sendRoomPartedBy(AbstractRoom room, AbstractUser user) throws UserDeadException
room
- The room from which someone has departeduser
- The user who has departed from the room
UserDeadException
- if the user has been disconnectedpublic void sendRoomUserCount(AbstractRoom room) throws UserDeadException
room
- The room whose user count is being updated
UserDeadException
- if the user has been disconnectedpublic void sendRoomVar(int roomNum, String varName, String varValue) throws UserDeadException
roomNum
- The room number for which the variable is being
setvarName
- The name of the room variablevarValue
- The new value of the variable
UserDeadException
- if the user has been disconnectedpublic void sendSuccessReply(String source, org.json.JSONObject resultIn, AbstractUser u, int room) throws org.json.JSONException
source
- the method returning successresultIn
- additional information to be returned to the
clientu
- the user responsible for the successful reply (ignored)room
- the room in which the user is standing (ignored)
org.json.JSONException
- if the success reply can't be encoded in
JSON form@Deprecated public void sendUserPart(AbstractUser user, AbstractRoom room) throws UserDeadException
#sendRoomPartedBy(Room, AbstractUser)
user
- The user departing from the roomroom
- The room from which the user has departed
UserDeadException
- if the user has been disconnectedpublic void sendUserVariable(User user, String varName, String varValue) throws UserDeadException
user
- The user whose variable has been updatedvarName
- The name of the user variablevarValue
- The new value of the user variable
UserDeadException
- if the user has been disconnectedpublic void setBusyState(boolean b)
setBusyState
in interface org.starhope.util.types.CanProcessCommands
b
- true, if the thread is in a busy state and should not be
interrupted for idle timeoutpublic void setDebug(boolean newDebug)
newDebug
- True, if the server should be in debug mode;
else, falsepublic void setLastInputTime(long thatTime)
setLastInputTime
in interface org.starhope.util.types.CanProcessCommands
thatTime
- the time of last input from the clientpublic void setLoggedIn(boolean amILoggedInNow)
amILoggedInNow
- True, if the thread represents a logged-in
userpublic void setSFSVersion(float smartFoxServerCommProtocolVersion)
smartFoxServerCommProtocolVersion
- The protocol version to
be used. This version of the server supports Smart Fox
Server Pro version 1.58, or Cubist JSON form using the
value Double.POSITIVE_INFINITYprivate void setup() throws IOException, UserDeadException
IOException
- if the I/O streams can't be initialized
UserDeadException
- if the user disconnects before setup is
completepublic void tattle(String message)
message
- messagepublic void tattle(String tattle, boolean urgent)
tattle
- the log entry to be printedurgent
- Display this message even in non-debug mode (in
logs)public void tick(long t, long dT) throws UserDeadException
tick
in interface AcceptsMetronomeTicks
t
- The value of System.currentTimeMillis at the start of
this tickdT
- The delta-T since the prior tick
UserDeadException
- if the user has been disconnectedprivate boolean tick_checkIdleKick(long tIdle) throws UserDeadException
tIdle
- Time that the user has been idle (milliseconds)
UserDeadException
- if the user is disconnectedprivate boolean tick_checkIdleWarnTime(long tIdle) throws UserDeadException
tIdle
- The time that this connection or user has been idle
UserDeadException
- if the user went awaypublic String toString()
toString
in class Thread
Thread.toString()
public void uncaughtException(Thread t, Throwable e)
uncaughtException
in interface Thread.UncaughtExceptionHandler
Thread.UncaughtExceptionHandler.uncaughtException(java.lang.Thread,
java.lang.Throwable)
private String userDebug(String string)
string
- The debugging code to append to the message
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |