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.
-
inputStream
- This makes it easier to recieve messages from the socket connection which we accepted
-
listenPort
- can be set at runtime with the -listenPort option
-
mudAllowed
- can be set at runtime with the -startmud or +startmud options
-
mudClient
- Provides access to all that cool mud stuff.
-
mudHost
- can be set at runtime with the -host option
-
mudPort
- can be set at runtime with the -host option
-
mudThread
-
-
outputStream
- This makes it easier to send messages to the socket connection which we accepted
-
Demon(String[])
-
-
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 ...)
-
getParameter(String, String[])
- all search strings are assumed to start with a + or -
anything else is assumed to be an argument string.
-
handleEndOfInput(Socket)
-
-
handleInput(String, Socket)
-
-
main(String[])
-
-
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)
-
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.
mudThread
protected Thread mudThread
mudClient
protected static MudClient mudClient
- Provides access to all that cool mud stuff.
- See Also:
- MudClient
mudHost
protected String mudHost
- can be set at runtime with the -host option
mudPort
protected int mudPort
- can be set at runtime with the -host option
listenPort
protected int listenPort
- can be set at runtime with the -listenPort option
mudAllowed
protected boolean mudAllowed
- can be set at runtime with the -startmud or +startmud options
outputStream
protected PrintStream outputStream
- This makes it easier to send messages to the socket connection which we accepted
inputStream
protected DataInputStream inputStream
- This makes it easier to recieve messages from the socket connection which we accepted
Demon
public Demon(String argv[])
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 ...)
main
public static void main(String argv[])
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)
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
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.
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.
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