com.planet_ink.coffee_mud.application
Class MUD

java.lang.Object
  extended by java.lang.Thread
      extended by com.planet_ink.coffee_mud.application.MUD
All Implemented Interfaces:
MudHost, java.lang.Runnable

public class MUD
extends java.lang.Thread
implements MudHost


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  boolean acceptConnections
           
protected static boolean bringDown
           
protected  java.lang.String host
           
protected static boolean isOK
           
protected  int port
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface com.planet_ink.coffee_mud.core.interfaces.MudHost
MAIN_HOST, TIME_SAVETHREAD_SLEEP, TIME_UTILTHREAD_SLEEP
 
Constructor Summary
MUD(java.lang.String name)
           
 
Method Summary
 void acceptConnection(java.net.Socket sock)
          Handles a connection from a user, and internal states
static int activeThreadCount(java.lang.ThreadGroup tGroup)
           
static void defaultShutdown()
           
 java.lang.String executeCommand(java.lang.String cmd)
          Flexible interface for tinkering with mud-host settings.
static void fatalStartupError(java.lang.Thread t, int type)
           
 java.lang.String getHost()
          the hostname of the mud server
 java.util.Vector getOverdueThreads()
          Return any internal threads that are a source of troubles
 int getPort()
          the port a given MUD server instance is listening on
 java.lang.String getStatus()
          Retreive a string telling the status of mud startup or shutdown
static void globalShutdown(Session S, boolean keepItDown, java.lang.String externalCommand)
           
protected static boolean initHost(java.lang.Thread t)
           
 void interrupt()
           
 boolean isAcceptingConnections()
          Sets whether this mud is accepting connections
static int killCount(java.lang.ThreadGroup tGroup, java.lang.Thread thisOne)
           
static void main(java.lang.String[] a)
           
 void run()
           
 void setAcceptConnections(boolean truefalse)
          Sets whether this mud is accepting connections
 void shutdown(Session S, boolean keepItDown, java.lang.String externalCommand)
          An order to permanently shutdown the entire mud system
static void threadList(java.lang.ThreadGroup tGroup)
           
 
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, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bringDown

protected static boolean bringDown

isOK

protected static boolean isOK

acceptConnections

protected boolean acceptConnections

host

protected java.lang.String host

port

protected int port
Constructor Detail

MUD

public MUD(java.lang.String name)
Method Detail

fatalStartupError

public static void fatalStartupError(java.lang.Thread t,
                                     int type)

initHost

protected static boolean initHost(java.lang.Thread t)

acceptConnection

public void acceptConnection(java.net.Socket sock)
                      throws java.net.SocketException,
                             java.io.IOException
Description copied from interface: MudHost
Handles a connection from a user, and internal states

Specified by:
acceptConnection in interface MudHost
Parameters:
sock - the socket the connection was made on
Throws:
java.net.SocketException
java.io.IOException

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getStatus

public java.lang.String getStatus()
Description copied from interface: MudHost
Retreive a string telling the status of mud startup or shutdown

Specified by:
getStatus in interface MudHost
Returns:
status of mud startup or shutdown

shutdown

public void shutdown(Session S,
                     boolean keepItDown,
                     java.lang.String externalCommand)
Description copied from interface: MudHost
An order to permanently shutdown the entire mud system

Specified by:
shutdown in interface MudHost
Parameters:
S - a player session to send status messages to. May be null.
keepItDown - true to shutdown, false to restart
externalCommand - if keepItDown is false, an external command to execute

defaultShutdown

public static void defaultShutdown()

globalShutdown

public static void globalShutdown(Session S,
                                  boolean keepItDown,
                                  java.lang.String externalCommand)

interrupt

public void interrupt()
Overrides:
interrupt in class java.lang.Thread

activeThreadCount

public static int activeThreadCount(java.lang.ThreadGroup tGroup)

killCount

public static int killCount(java.lang.ThreadGroup tGroup,
                            java.lang.Thread thisOne)

threadList

public static void threadList(java.lang.ThreadGroup tGroup)

getHost

public java.lang.String getHost()
Description copied from interface: MudHost
the hostname of the mud server

Specified by:
getHost in interface MudHost
Returns:
hostname or ip address

getPort

public int getPort()
Description copied from interface: MudHost
the port a given MUD server instance is listening on

Specified by:
getPort in interface MudHost
Returns:
the port numbered listened on by this mud instance

getOverdueThreads

public java.util.Vector getOverdueThreads()
Description copied from interface: MudHost
Return any internal threads that are a source of troubles

Specified by:
getOverdueThreads in interface MudHost
Returns:
a list of threads that need service or killing

main

public static void main(java.lang.String[] a)

setAcceptConnections

public void setAcceptConnections(boolean truefalse)
Description copied from interface: MudHost
Sets whether this mud is accepting connections

Specified by:
setAcceptConnections in interface MudHost
Parameters:
truefalse - whether it is accepting connections
See Also:
MudHost.isAcceptingConnections()

isAcceptingConnections

public boolean isAcceptingConnections()
Description copied from interface: MudHost
Sets whether this mud is accepting connections

Specified by:
isAcceptingConnections in interface MudHost
See Also:
return true/false whether it is accepting connections

executeCommand

public java.lang.String executeCommand(java.lang.String cmd)
                                throws java.lang.Exception
Description copied from interface: MudHost
Flexible interface for tinkering with mud-host settings. Commands to be defined later, or now, or whatever.

Specified by:
executeCommand in interface MudHost
Parameters:
cmd - space-delimited (parsable) command/parm list
Returns:
any return variables
Throws:
java.lang.Exception