org.bluesock.bluemud.driver
Class User

java.lang.Object
  |
  +--org.bluesock.bluemud.driver.User

public class User
extends java.lang.Object

The User class serves as the bridge between the SocketCommunicator, which is responsible for low-level network I/O, and the Controller, which is responsible for interpretation of user commands and forwarding of world-generated messages to the user.


Constructor Summary
User(SocketCommunicator comm, java.lang.String connectedFromIPAddress)
          Constructor
 
Method Summary
 void disconnectEvent()
           
 Controller getController()
          Retrieve the Controller instance presently associated with this User instance.
 int getIdleTime()
          Retrieves the time, in seconds, that this User has been idle.
 java.lang.String getIPAddress()
          Retrieves the IP address from which this user is connected.
 java.lang.Object getProperty(java.lang.String key)
          Retrieves information from the properties HashMap.
 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.
(package private)  SecurityToken getSecurityToken()
          Retrieve the SecurityToken associated with this User instance.
 java.util.HashMap getSocketProperties()
          Returns a copy of the telnet properties HashMap.
 boolean inLineMode()
          Queries the SocketCommunicator as to whether we're in the almighty linemode or not.
 void inputEvent(java.lang.String incoming)
          Creates and enqueues a new Input Event.
 void logout()
          This tells the communicator to exit.
 void nawsEvent()
          Creates and enqueues a Naws Event.
 void rawwrite(java.lang.String message)
          Send a raw message to the user (over the Socketcommunicator).
 boolean setCharacterMode()
          Puts the connection into character mode (as opposed to line mode.
 void setController(Controller newController)
          Specify the controller this User should interact with.
 void setLineMode()
          Puts the connection into line mode.
(package private)  void setSecurityToken(SecurityToken token)
          Resets the security token associated with this User object.
 void setShouldExit(boolean b)
          Sets the shouldExit flag which will kick the User polling thread out of its loop and close the connection.
 void start()
           
 void turnOffEcho()
          Tells the user's client to stop echoing text (for passwords and such).
 void turnOnEcho()
          Tells the user's client to start echoing text (for regular stuff).
 void write(java.lang.String message)
          Send a message to the user (over the Socketcommunicator).
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

User

public User(SocketCommunicator comm,
            java.lang.String connectedFromIPAddress)
Constructor
Parameters:
comm - The SocketCommunicator instance this User is bound to for socket communications.
connectedFromIPAddress - The ip address from which the User connected.
Method Detail

setController

public void setController(Controller newController)
Specify the controller this User should interact with. This may be called more than once with different Controller instances.
Parameters:
newController - - The controller this User should begin interacting with.

getController

public Controller getController()
Retrieve the Controller instance presently associated with this User instance.

write

public void write(java.lang.String message)
Send a message to the user (over the Socketcommunicator). No newline is appended.
Parameters:
message - The message to send.

rawwrite

public void rawwrite(java.lang.String message)
Send a raw message to the user (over the Socketcommunicator). No translations are done to this data--it is sent as is to the user.
Parameters:
message - The message to send.

nawsEvent

public void nawsEvent()
Creates and enqueues a Naws Event. Naws events go to whatever is registered to receive them. This allows things like visual editors to refresh their screens according to the new size of the user's client.

inputEvent

public void inputEvent(java.lang.String incoming)
Creates and enqueues a new Input Event.
Parameters:
incoming - The text of the input.

disconnectEvent

public void disconnectEvent()

start

public void start()

getProperty

public java.lang.Object getProperty(java.lang.String key)
Retrieves information from the properties HashMap.
Returns:
the property being sought.

getProperty

public 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.
Returns:
the property being sought or the default.

getIPAddress

public java.lang.String getIPAddress()
Retrieves the IP address from which this user is connected.
Returns:
the IP address of the user.

getIdleTime

public int getIdleTime()
Retrieves the time, in seconds, that this User has been idle.
Returns:
the number of seconds sine this User entered a command.

setShouldExit

public void setShouldExit(boolean b)
Sets the shouldExit flag which will kick the User polling thread out of its loop and close the connection.

turnOnEcho

public void turnOnEcho()
Tells the user's client to start echoing text (for regular stuff).

turnOffEcho

public void turnOffEcho()
Tells the user's client to stop echoing text (for passwords and such).

setCharacterMode

public boolean setCharacterMode()
Puts the connection into character mode (as opposed to line mode. First it checks to see if the connection supports character mode--if not, it returns a false. FIXME This is a little klugy--we should kick up an exception instead of returning true/false.
Returns:
whether or not the connection can be put in character mode.

setLineMode

public void setLineMode()
Puts the connection into line mode.

inLineMode

public boolean inLineMode()
Queries the SocketCommunicator as to whether we're in the almighty linemode or not.
Returns:
true if we're in line mode, false if otherwise.

getSocketProperties

public java.util.HashMap getSocketProperties()
Returns a copy of the telnet properties HashMap. Useful for debugging.

logout

public void logout()
This tells the communicator to exit. The communicator will bump out of it's input-polling loop and close the sockets.

getSecurityToken

SecurityToken getSecurityToken()
Retrieve the SecurityToken associated with this User instance. This method is package-only access so that only other driver classes can access the security token.

setSecurityToken

void setSecurityToken(SecurityToken token)
Resets the security token associated with this User object. This User instance will gain whatever permissions are associated with the new SecurityToken instance. This method is package-only access so that only other driver classes can reset the security token.
Parameters:
token - The new SecurityToken


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