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
 
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, boolean nonDaemonsOnly)
           
static void defaultShutdown()
           
static void execExternalRestart()
           
 java.lang.String executeCommand(java.lang.String cmd)
          Flexible interface for tinkering with mud-host settings.
 java.lang.String getHost()
          the hostname of the mud server
 java.lang.String getLanguage()
          Return the viewable name of the language supported by this host.
 java.util.List<java.lang.Runnable> 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()
          Retrieve a string telling the status of mud startup or shutdown
 long getUptimeSecs()
          Retrieve the number of seconds since startup
 java.lang.String geWebHostUrl()
          The hostname, port of the most public web server for this host Includes trailing slash
static void globalShutdown(Session S, boolean keepItDown, java.lang.String externalCommand)
           
 void interrupt()
           
 boolean isAcceptingConnections()
          Sets whether this mud is accepting connections
static void main(java.lang.String[] a)
           
 void run()
           
 void setAcceptConnections(boolean truefalse)
          Sets whether this mud is accepting connections
 void setState(com.planet_ink.coffee_mud.application.MUD.MudState st)
           
 void shutdown(Session S, boolean keepItDown, java.lang.String externalCommand)
          An order to permanently shutdown the entire mud system
 java.lang.ThreadGroup threadGroup()
          Because thread groups are used to track configurations, here is a way to get it.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MUD

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

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 - socket exceptions
java.io.IOException - io exceptions

threadGroup

public java.lang.ThreadGroup threadGroup()
Description copied from interface: MudHost
Because thread groups are used to track configurations, here is a way to get it.

Specified by:
threadGroup in interface MudHost
Returns:
the thread group this host was created under.

getLanguage

public java.lang.String getLanguage()
Description copied from interface: MudHost
Return the viewable name of the language supported by this host.

Specified by:
getLanguage in interface MudHost
Returns:
the language supported by this host.

setState

public void setState(com.planet_ink.coffee_mud.application.MUD.MudState st)

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
Retrieve 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,
                                    boolean nonDaemonsOnly)

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

geWebHostUrl

public java.lang.String geWebHostUrl()
Description copied from interface: MudHost
The hostname, port of the most public web server for this host Includes trailing slash

Specified by:
geWebHostUrl in interface MudHost
Returns:
http://mydomain:myport/

getOverdueThreads

public java.util.List<java.lang.Runnable> 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)

execExternalRestart

public static void execExternalRestart()

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
Returns:
true/false whether it is accepting connections
See Also:
MudHost.setAcceptConnections(boolean)

getUptimeSecs

public long getUptimeSecs()
Description copied from interface: MudHost
Retrieve the number of seconds since startup

Specified by:
getUptimeSecs in interface MudHost
Returns:
number of seconds since startup

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 - any exceptions