Class PALplate.mud.Demon
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class PALplate.mud.Demon

java.lang.Object
   |
   +----PALplate.mud.Demon

public class Demon
extends Object
implements Runnable
This is the main class for any Demon application. It can handle multiple incoming socket connections from different appliances and forward strings onwards to the demon associated with it. It handles the socket connections serially, rather than giving each a different thread, because we want to serialize the input to the mud: the demon, for now, is only expected to do one thing at a time. To make this class more general, I may have serial vs parallel be an option which can be specified in the constructor. The defalut behaviour for a demon is to do nothing in the mud with the strings it recieves (it does print them to stdout for debugging purposes): I considered having it send the strings to the mud by default, but this would be quite dangerous in terms of security (the strings would be executed by the mud with all the permissions of the demon). So people will have to subclass to make this class useful.

Variable Index

 o inputStream
This makes it easier to recieve messages from the socket connection which we accepted
 o listenPort
can be set at runtime with the -listenPort option
 o mudAllowed
can be set at runtime with the -startmud or +startmud options
 o mudClient
Provides access to all that cool mud stuff.
 o mudHost
can be set at runtime with the -host option
 o mudPort
can be set at runtime with the -host option
 o mudThread
 o outputStream
This makes it easier to send messages to the socket connection which we accepted

Constructor Index

 o Demon(String[])

Method Index

 o destroy()
Sends a quit command and closes the sockets (which by then a broken, so you may get an error but this way we can be doubly sure ...)
 o getParameter(String, String[])
all search strings are assumed to start with a + or - anything else is assumed to be an argument string.
 o handleEndOfInput(Socket)
 o handleInput(String, Socket)
 o main(String[])
 o parse_arguments(String[])
Parameters which can be passed to this application are:

-host --(mud host machine)

-port --(mud port)

-startmud --(don't start mud)

+startmud --(do start mud)

-startapp --(class which displays mud stuff)

-demonName --(for logging in to mud)

-demonPassword --(for logging in to mud)

 o run()
This function loops, repeatedly blocking until someone connects, handling all input from the connection, and then closing it and blocking again until someone connects.

Variables

 o mudThread
  protected Thread mudThread
 o mudClient
  protected static MudClient mudClient
Provides access to all that cool mud stuff.
See Also:
MudClient
 o mudHost
  protected String mudHost
can be set at runtime with the -host option
 o mudPort
  protected int mudPort
can be set at runtime with the -host option
 o listenPort
  protected int listenPort
can be set at runtime with the -listenPort option
 o mudAllowed
  protected boolean mudAllowed
can be set at runtime with the -startmud or +startmud options
 o outputStream
  protected PrintStream outputStream
This makes it easier to send messages to the socket connection which we accepted
 o inputStream
  protected DataInputStream inputStream
This makes it easier to recieve messages from the socket connection which we accepted

Constructors

 o Demon
  public Demon(String argv[])

Methods

 o destroy
  public void destroy()
Sends a quit command and closes the sockets (which by then a broken, so you may get an error but this way we can be doubly sure ...)
 o main
  public static void main(String argv[])
 o parse_arguments
  public boolean parse_arguments(String argv[])
Parameters which can be passed to this application are:

-host --(mud host machine)

-port --(mud port)

-startmud --(don't start mud)

+startmud --(do start mud)

-startapp --(class which displays mud stuff)

-demonName --(for logging in to mud)

-demonPassword --(for logging in to mud)

 o getParameter
  public String getParameter(String searchString,
                             String argv[])
all search strings are assumed to start with a + or - anything else is assumed to be an argument string. Returns null if searchString doesn't occur in argv Returns "" if searchString occurs but has no arguments Returns argString if searchString has arguments
 o run
  public void run()
This function loops, repeatedly blocking until someone connects, handling all input from the connection, and then closing it and blocking again until someone connects. Eventually, it may have the option to handle incoming connections in parallel instead of in sequence as it does now.
 o handleInput
  protected void handleInput(String inputLine,
                             Socket s)
Parameters:
inputLine - The line just recieved
s - The socket it was recieved on (this might be needed if we switch to handling sockets in parallel instead of in series.
 o handleEndOfInput
  protected void handleEndOfInput(Socket s)
Parameters:
s - The socket it was recieved on (this might be needed if we switch to handling sockets in parallel instead of in series.

All Packages  Class Hierarchy  This Package  Previous  Next  Index