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

Class PALplate.mud.MudClient

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

public class MudClient
extends Object
implements Runnable
MudClient is used as a separate thread by java classes connected to the mud. Only one copy of the MudClient should be running per user. It takes care of requests for mud information from any class (they pass it a pointer) and keeps the connection current.

In order to be accessable to applets (and objects) in other frames, all of the variables and methods involved in applet to mud communication are static. This is the main class for any client of the mud. Variations on it inherit from it.


Variable Index

 o GuestName
This is static because they are used in static functions.
 o GuestPassword
This is static because they are used in static functions.
 o keepRunning
This is public so that other classes can change it in order to control whether or not the mud will stay connected.
 o outputStream
 o prefix
 o tryToStayConnected

Constructor Index

 o MudClient(String, int)
Initializes stuff and connects to the mud.
 o MudClient(String, int, String)
Initializes stuff and connects to the mud.

Method Index

 o authenticatedConnect(String, String)
Opens a connection to the mud server

 o closeConnection()
 o dealWithDisconnectedInputLine()
 o dealWithInputLine(String)
 o dealWithInvalidAccount()
 o dealWithMCPInputLine(String)
 o dealWithNullInputLine()
 o dealWithPrefixInputLine(String)
 o dealWithRedirectedAccount()
If we stole the connection from someone, allow them to steal it back without fighting over it.
 o dealWithValidAccount()
 o openConnection()
Opens a connection to the mud server
 o ParseMudData(String, boolean)
 o RegisterForMudCommand(String, Object)
Use this to register yourself for a tag when there's no command to send
 o RemoveMudCommand(String)
Use this to remove any references to any objects associated with tag.
 o RemoveMudCommand(String, Object)
Use this to remove any references to a specific object associated with tag.
 o run()
The main loop.
 o SendLine(String)
Sends a line of text to the mud server.
 o SendMudCommand(String)
Use this to send a mud command for which you expect no response.
 o SendMudCommand(String, String, MudComm)
Use this to register yourself for a response and send a mud command all in one.

Variables

 o outputStream
  public static PrintStream outputStream
 o prefix
  protected String prefix
 o keepRunning
  public static boolean keepRunning
This is public so that other classes can change it in order to control whether or not the mud will stay connected.
See Also:
destroy, run
 o tryToStayConnected
  public boolean tryToStayConnected
 o GuestName
  public static String GuestName
This is static because they are used in static functions. It is public so that other classes can set it.
See Also:
processParameters
 o GuestPassword
  public static String GuestPassword
This is static because they are used in static functions. It is public so that other classes can set it.
See Also:
processParameters

Constructors

 o MudClient
  public MudClient(String host,
                   int port)
Initializes stuff and connects to the mud.
Parameters:
host - The host at which I can find the mud
port - The port at which I can find the mud
 o MudClient
  public MudClient(String host,
                   int port,
                   String pr)
Initializes stuff and connects to the mud.
Parameters:
host - The host at which I can find the mud
port - The port at which I can find the mud
prefix - The string which prepends "lines of interest"

Methods

 o run
  public void run()
The main loop. As long as keepRunning is true, it keeps going ... and going ... and going :)

If we get disconnected for any reason, it tries to reconnect. Otherwise it reads input, and parses out MCP protocol commands (does nothing with them) as well as #@# commands (information that has been requested by PermFrame), which it sends on to the requestor(s) that registered that tag

See the architecture">docs for more information on parsing formats and stuff.

 o dealWithInputLine
  protected boolean dealWithInputLine(String inputLine)
Returns:
Whether or not to keep running.
 o dealWithNullInputLine
  protected boolean dealWithNullInputLine()
Returns:
Whether or not to keep running.
 o dealWithDisconnectedInputLine
  protected boolean dealWithDisconnectedInputLine()
Returns:
Whether or not to keep running.
 o dealWithInvalidAccount
  protected boolean dealWithInvalidAccount()
Returns:
Whether or not to keep running.
 o dealWithValidAccount
  protected boolean dealWithValidAccount()
Returns:
Whether or not to keep running.
 o dealWithRedirectedAccount
  protected boolean dealWithRedirectedAccount()
If we stole the connection from someone, allow them to steal it back without fighting over it.
Returns:
Whether or not to keep running.
 o dealWithPrefixInputLine
  protected boolean dealWithPrefixInputLine(String inputLine)
Returns:
Whether or not to keep running.
 o dealWithMCPInputLine
  protected boolean dealWithMCPInputLine(String inputLine)
Returns:
Whether or not to keep running.
 o SendLine
  public static boolean SendLine(String line)
Sends a line of text to the mud server. Static (a class method) so thatny object anywhere can call it ...
Returns:
true on success in sending the line. false otherwise.
 o openConnection
  public synchronized void openConnection()
Opens a connection to the mud server
 o closeConnection
  public synchronized void closeConnection()
 o authenticatedConnect
  public static boolean authenticatedConnect(String player,
                                             String password)
Opens a connection to the mud server

Parameters:
name - The name of the character to connect as
password - The password of the character to connect as
Returns:
true on succesful login, false otherwise
 o SendMudCommand
  public static boolean SendMudCommand(String tag,
                                       String command,
                                       MudComm requestor)
Use this to register yourself for a response and send a mud command all in one.

See the architecture">docs for more information on parsing formats and stuff.

Parameters:
tag - The tag assocated with the request
command - The actual command. The tag will be appened on to this command (after a space) when sent to the mud.
requestor - A reference to the object making the request
Returns:
true if the line was sent successfully, false otherwise
 o RemoveMudCommand
  public static boolean RemoveMudCommand(String tag)
Use this to remove any references to any objects associated with tag. If a response with tag arrives, it will be ignored
Parameters:
tag - The tag to remove from the vector of possible responses.
Returns:
true if the command was registered, false otherwise
 o RemoveMudCommand
  public static boolean RemoveMudCommand(String tag,
                                         Object requestor)
Use this to remove any references to a specific object associated with tag. If a response with tag arrives, it will still be sent to any other registered objects.
Parameters:
requestor - The object to remove from the vector of registered objects
tag - The tag for which that object should be removed.
Returns:
true if the command was registered for requestor, false otherwise
 o SendMudCommand
  public static boolean SendMudCommand(String command)
Use this to send a mud command for which you expect no response.
Parameters:
command - The string to send to the mud.
Returns:
true if the line was sent successfully, false otherwise
 o RegisterForMudCommand
  public static boolean RegisterForMudCommand(String tag,
                                              Object requestor)
Use this to register yourself for a tag when there's no command to send
Parameters:
requestor - The object registering itself
tag - The tag it's registering for
Returns:
true if the requestor had already been registered for that tag, false otherwise
 o ParseMudData
  public static synchronized Object ParseMudData(String str,
                                                 boolean debug)
Parameters:
str - A mud data type (see parser.cup for the specs)

All Packages  Class Hierarchy  This Package  Previous  Next  Index