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.
-
GuestName
- This is static because they are used in static functions.
-
GuestPassword
- This is static because they are used in static functions.
-
keepRunning
- This is public so that other classes can change it in order to control whether or not the mud will stay connected.
-
outputStream
-
-
prefix
-
-
tryToStayConnected
-
-
MudClient(String, int)
- Initializes stuff and connects to the mud.
-
MudClient(String, int, String)
- Initializes stuff and connects to the mud.
-
authenticatedConnect(String, String)
- Opens a connection to the mud server
-
closeConnection()
-
-
dealWithDisconnectedInputLine()
-
-
dealWithInputLine(String)
-
-
dealWithInvalidAccount()
-
-
dealWithMCPInputLine(String)
-
-
dealWithNullInputLine()
-
-
dealWithPrefixInputLine(String)
-
-
dealWithRedirectedAccount()
-
If we stole the connection from someone, allow them to steal it back without
fighting over it.
-
dealWithValidAccount()
-
-
openConnection()
-
Opens a connection to the mud server
-
ParseMudData(String, boolean)
-
-
RegisterForMudCommand(String, Object)
- Use this to register yourself for a tag when there's no command to send
-
RemoveMudCommand(String)
- Use this to remove any references to any objects associated with tag.
-
RemoveMudCommand(String, Object)
- Use this to remove any references to a specific object associated with tag.
-
run()
- The main loop.
-
SendLine(String)
-
Sends a line of text to the mud server.
-
SendMudCommand(String)
- Use this to send a mud command for which you expect no response.
-
SendMudCommand(String, String, MudComm)
- Use this to register yourself for a response and send a mud command all in one.
outputStream
public static PrintStream outputStream
prefix
protected String prefix
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
tryToStayConnected
public boolean tryToStayConnected
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
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
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
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"
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.
dealWithInputLine
protected boolean dealWithInputLine(String inputLine)
- Returns:
- Whether or not to keep running.
dealWithNullInputLine
protected boolean dealWithNullInputLine()
- Returns:
- Whether or not to keep running.
dealWithDisconnectedInputLine
protected boolean dealWithDisconnectedInputLine()
- Returns:
- Whether or not to keep running.
dealWithInvalidAccount
protected boolean dealWithInvalidAccount()
- Returns:
- Whether or not to keep running.
dealWithValidAccount
protected boolean dealWithValidAccount()
- Returns:
- Whether or not to keep running.
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.
dealWithPrefixInputLine
protected boolean dealWithPrefixInputLine(String inputLine)
- Returns:
- Whether or not to keep running.
dealWithMCPInputLine
protected boolean dealWithMCPInputLine(String inputLine)
- Returns:
- Whether or not to keep running.
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.
openConnection
public synchronized void openConnection()
- Opens a connection to the mud server
closeConnection
public synchronized void closeConnection()
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
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
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
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
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
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
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