org.bluesock.bluemud.driver
Class SocketCommunicator

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.bluesock.bluemud.driver.SocketCommunicator
All Implemented Interfaces:
java.lang.Runnable

public class SocketCommunicator
extends java.lang.Thread

This communicator abstracts the User object (which encapsulates a user on the mud) from the actual telnet connection they have. SocketCommunicator handles Telnet socket connections. It acts like a scaled down telnet daemon in that it handles telnet options and responds to them as specified in the telnet protocol RFC. It also handles building InputEvents and enqueueing them in the engine.


Fields inherited from class java.lang.Thread
inheritableThreadLocals, MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, threadLocals
 
Constructor Summary
(package private) SocketCommunicator(java.net.Socket connectedSocket)
          Constructor.
 
Method Summary
(package private)  void characterMode()
          Switches the socket into character mode.
 void disconnect()
          Handles disconnection of the socket.
(package private)  void echoOff()
          Turns echo off for the client.
(package private)  void echoOn()
          Turns echo on for the client.
 void flush()
          Forces a flush on the output stream.
(package private)  java.util.HashMap getProperties()
          Returns a copy of the properties hashmap for us to dump/view.
(package private)  java.lang.Object getProperty(java.lang.String key)
          Retrieves information from the properties HashMap.
(package private)  java.lang.Object getProperty(java.lang.String key, java.lang.Object def)
          Retrieves information from the properties HashMap and if it's not there, it returns the default.
 void initializeSocketCommunicator(User user)
          Initializes properties.
 boolean inLineMode()
           
(package private)  void lineMode()
          Switches this socket into line mode.
 void print(java.lang.String message)
          Prints a string to the output stream after converting LF to CRLF.
 void print(User user, java.lang.String message)
          Prints a string to the output stream after converting LF to CRLF.
 void rawprint(char message)
          Prints a string raw to the output stream--no conversions.
 void rawprint(char[] message)
          Prints a string raw to the output stream--no conversions.
 void rawprint(User user, java.lang.String message)
          Prints a string raw to the output stream--no conversions.
 void run()
          Handles reading lines from the input stream.
 void setShouldExit(boolean b)
          If the boolean passed in is a true, this will stop the network thread reading for this User.
(package private)  void sgaOff()
           
(package private)  void sgaOn()
           
(package private)  boolean supports(User user, java.lang.String property)
          The SocketCommunicator knows about what the thing on the other end of this socket supports.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SocketCommunicator

SocketCommunicator(java.net.Socket connectedSocket)
Constructor.
Parameters:
connectedSocket - the Socket that we're wrapping around.
Method Detail

initializeSocketCommunicator

public void initializeSocketCommunicator(User user)
Initializes properties.
Parameters:
user - the User object that is associated with this SocketConnector.

disconnect

public void disconnect()
Handles disconnection of the socket.

print

public void print(User user,
                  java.lang.String message)
Prints a string to the output stream after converting LF to CRLF. Keep in mind that it's important that calls to this function are atomic--make sure you buffer what you're sending out before you send it. Otherwise it's possible for it to be "interrupted" with text coming from elsewhere.
Parameters:
user - the user object that we're sending data to--currently we don't use this for anything, but we might need to check the user for properties later on.
message - the outgoing message.

rawprint

public void rawprint(User user,
                     java.lang.String message)
Prints a string raw to the output stream--no conversions. Keep in mind that it's important that calls to this function are atomic--make sure you buffer what you're sending out before you send it. Otherwise it's possible for it to be "interrupted" with text coming from elsewhere.
Parameters:
user - the user object that we're sending data to--currently we don't use this for anything, but we might need to check the user for properties later on.
message - the outgoing message.

print

public void print(java.lang.String message)
Prints a string to the output stream after converting LF to CRLF. Keep in mind that it's important that calls to this function are atomic--make sure you buffer what you're sending out before you send it. Otherwise it's possible for it to be "interrupted" with text coming from elsewhere.
Parameters:
message - the outgoing data

rawprint

public void rawprint(char[] message)
Prints a string raw to the output stream--no conversions. Keep in mind that it's important that calls to this function are atomic--make sure you buffer what you're sending out before you send it. Otherwise it's possible for it to be "interrupted" with text coming from elsewhere.
Parameters:
message - the outgoing data

rawprint

public void rawprint(char message)
Prints a string raw to the output stream--no conversions. Keep in mind that it's important that calls to this function are atomic--make sure you buffer what you're sending out before you send it. Otherwise it's possible for it to be "interrupted" with text coming from elsewhere.
Parameters:
message - the outgoing data

flush

public void flush()
Forces a flush on the output stream. Typically we won't need this. I provided it in case we find we do.

setShouldExit

public void setShouldExit(boolean b)
If the boolean passed in is a true, this will stop the network thread reading for this User.
Parameters:
b - What to set shouldExit flag to.

run

public void run()
Handles reading lines from the input stream. A line ends with one of the many EOL possibilities. If it encounters a 255 (TelnetConstants.IAC), then it kicks it over to _handleNego which deals with telnet control codes and telnet options and the like.
Overrides:
run in class java.lang.Thread

echoOn

void echoOn()
Turns echo on for the client.

echoOff

void echoOff()
Turns echo off for the client.

sgaOn

void sgaOn()

sgaOff

void sgaOff()

lineMode

void lineMode()
Switches this socket into line mode.

characterMode

void characterMode()
Switches the socket into character mode.

inLineMode

public boolean inLineMode()

supports

boolean supports(User user,
                 java.lang.String property)
The SocketCommunicator knows about what the thing on the other end of this socket supports. So we abstract the thing right out. FIXME - this is totally hacked in right now until I figure out a better way of doing it. Maybe a TERMIO/TERMCAP kind of db.
Parameters:
user - The user object (we techically don't need this i think).
property - The property to check to see if their terminal type supports it.

getProperty

java.lang.Object getProperty(java.lang.String key)
Retrieves information from the properties HashMap.
Parameters:
key - The key of the property to retrieve.
Returns:
the property.

getProperty

java.lang.Object getProperty(java.lang.String key,
                             java.lang.Object def)
Retrieves information from the properties HashMap and if it's not there, it returns the default.
Parameters:
key - The key of the property to retrieve.
def - The default value to return if the the key isn't there.
Returns:
the property.

getProperties

java.util.HashMap getProperties()
Returns a copy of the properties hashmap for us to dump/view.


docs generated on Thu Jan 24 08:57:26 CST 2002