com.planet_ink.coffee_mud.Common
Class DefaultSession

java.lang.Object
  extended by com.planet_ink.coffee_mud.Common.DefaultSession
All Implemented Interfaces:
CMCommon, Session, CMObject, Modifiable, CMRunnable, java.lang.Cloneable, java.lang.Comparable<CMObject>, java.lang.Runnable

public class DefaultSession
extends java.lang.Object
implements Session


Nested Class Summary
static class DefaultSession.LoginLogoutThread
           
 
Nested classes/interfaces inherited from interface com.planet_ink.coffee_mud.Common.interfaces.Session
Session.InputCallback, Session.SessionStatus, Session.TickingCallback
 
Field Summary
protected  PlayerAccount acct
           
protected  long activeMillis
           
protected  boolean afkFlag
           
protected  java.lang.String afkMessage
           
protected  boolean bNextByteIs255
           
protected  com.planet_ink.coffee_mud.Common.DefaultSession.SesInputStream charWriter
           
protected  boolean[] clientTelnetCodes
           
protected  java.lang.String[] clookup
           
protected  boolean connectionComplete
           
protected  java.lang.StringBuffer curPrevMsg
           
protected  ColorLibrary.ColorState currentColor
           
protected  boolean debugBinInput
           
protected  java.lang.StringBuffer debugBinInputBuf
           
protected  boolean debugBinOutput
           
protected  boolean debugStrInput
           
protected  java.lang.StringBuffer fakeInput
           
protected  java.util.Map<java.lang.String,java.lang.Long> gmcpPings
           
protected  java.util.Map<java.lang.String,java.lang.Double> gmcpSupports
           
protected  java.lang.String groupName
           
protected  java.io.BufferedReader in
           
protected  int inMaxBytesPerChar
           
protected  java.lang.StringBuffer input
           
protected  Session.InputCallback inputCallback
           
protected  boolean killFlag
           
protected  long lastBlahCheck
           
protected  ColorLibrary.ColorState lastColor
           
protected  java.lang.String lastColorStr
           
protected  long lastIACIn
           
protected  long lastKeystroke
           
protected  long lastLoopTop
           
protected  long lastNPCFight
           
protected  long lastPKFight
           
protected  long lastStart
           
protected  long lastStateChangeMs
           
protected  long lastStop
           
protected  java.lang.String lastStr
           
protected  boolean lastWasCR
           
protected  boolean lastWasLF
           
protected  long lastWriteTime
           
protected  boolean[] loggingOutObj
           
protected  CharCreationLibrary.LoginSession loginSession
           
protected  boolean mcpDisabled
           
protected  java.lang.String[] mcpKey
           
protected  java.util.Map<java.lang.String,java.lang.String> mcpKeyPairs
           
protected  java.util.Map<java.lang.String,float[]> mcpSupported
           
protected  long milliTotal
           
protected  MOB mob
           
protected static int MSDPPINGINTERVAL
           
protected  java.util.Map<java.lang.Object,java.lang.Object> msdpReportables
           
protected  java.util.Set<java.lang.String> mxpSupportSet
           
protected  java.util.Map<java.lang.String,java.lang.String> mxpVersionInfo
           
protected  boolean needPrompt
           
protected  long nextMsdpPing
           
protected  long onlineTime
           
protected  java.io.PrintWriter out
           
protected static char[] PINGCHARS
           
protected static int PINGTIMEOUT
           
protected  java.util.List<java.lang.String> previousCmd
           
protected  java.util.List<java.lang.String> prevMsgs
           
protected  long promptLastShown
           
protected  byte[] promptSuffix
           
protected  java.io.InputStream rawin
           
protected  java.io.OutputStream rawout
           
protected  boolean[] serverTelnetCodes
           
protected  java.util.List<Session> snoops
           
protected  int snoopSuspensionStack
           
protected  java.net.Socket sock
           
protected  java.util.concurrent.atomic.AtomicBoolean sockObj
           
protected static int SOTIMEOUT
           
protected  int spamStack
           
protected  Session.SessionStatus status
           
protected  boolean suspendCommandLine
           
protected  java.util.Set<java.lang.Integer> telnetSupportSet
           
protected  int terminalHeight
           
protected  java.lang.String terminalType
           
protected  int terminalWidth
           
protected  char threadGroupChar
           
protected  long tickTotal
           
protected  long userLoginTime
           
protected  boolean waiting
           
protected  java.util.concurrent.locks.ReentrantLock writeLock
           
protected  long writeStartTime
           
 
Fields inherited from interface com.planet_ink.coffee_mud.Common.interfaces.Session
MAX_PREVMSGS, MSDP_ARRAY_CLOSE, MSDP_ARRAY_OPEN, MSDP_CHARSET, MSDP_TABLE_CLOSE, MSDP_TABLE_OPEN, MSDP_VAL, MSDP_VAR, TELNET_AARD, TELNET_ANSI, TELNET_ATCP, TELNET_AYT, TELNET_BINARY, TELNET_COMPRESS, TELNET_COMPRESS2, TELNET_DESCS, TELNET_DO, TELNET_DONT, TELNET_EC, TELNET_ECHO, TELNET_GA, TELNET_GMCP, TELNET_IAC, TELNET_LINEMODE, TELNET_LINEMODE_MODE, TELNET_LINEMODE_MODEMASK_ACK, TELNET_LINEMODE_MODEMASK_EDIT, TELNET_LINEMODE_MODEMASK_TRAPSIG, TELNET_LINEMODE_SLC, TELNET_LINEMODE_SLC_ACK, TELNET_LINEMODE_SLC_AO, TELNET_LINEMODE_SLC_AYT, TELNET_LINEMODE_SLC_BRK, TELNET_LINEMODE_SLC_CANTCHANGE, TELNET_LINEMODE_SLC_DEFAULT, TELNET_LINEMODE_SLC_EOF, TELNET_LINEMODE_SLC_EOR, TELNET_LINEMODE_SLC_IP, TELNET_LINEMODE_SLC_NOSUPPORT, TELNET_LINEMODE_SLC_SUSP, TELNET_LINEMODE_SLC_VALUE, TELNET_LINEMODE_SLC_XOFF, TELNET_LINEMODE_SLC_XON, TELNET_LOGOUT, TELNET_MSDP, TELNET_MSP, TELNET_MSSP, TELNET_MXP, TELNET_NAWS, TELNET_NOP, TELNET_SB, TELNET_SE, TELNET_SUPRESS_GO_AHEAD, TELNET_TERMTYPE, TELNET_TOGGLE_FLOW_CONTROL, TELNET_WILL, TELNET_WONT, TELNETBYTES_END_SB, TELNETBYTES_GMCP_HEAD, TELNETGABYTES
 
Constructor Summary
DefaultSession()
           
 
Method Summary
 long activeTimeMillis()
          Returns the number of milliseconds this runnable has been running.
 boolean autoLogin(java.lang.String name, java.lang.String password)
          If the session is in a non-logged in state (or even if it is), this will automatically login the user with the given name and password, and switch the session to the main loop.
 java.lang.String blockingIn()
           
 java.lang.String blockingIn(long maxTime, boolean filter)
          Blocks the current thread until the user attached to this session hits ENTER, returning the characters they enter.
 void changeTelnetMode(int telnetCode, boolean onOff)
          Change telnet mode by sending the appropriate command to the clients client.
 void changeTelnetModeBackwards(int telnetCode, boolean onOff)
           
 void changeTelnetModeBackwards(java.io.OutputStream out, int telnetCode, boolean onOff)
           
 java.lang.String choose(java.lang.String Message, java.lang.String Choices, java.lang.String Default)
          Prompts the user to enter one character responses from a set of valid choices.
 java.lang.String choose(java.lang.String Message, java.lang.String Choices, java.lang.String Default, long maxTime)
          Prompts the user to enter one character responses from a set of valid choices.
 java.lang.String choose(java.lang.String Message, java.lang.String Choices, java.lang.String Default, long maxTime, java.util.List<java.lang.String> paramsOut)
          Prompts the user to enter one character responses from a set of valid choices.
protected  void clearInputBuffer(long maxTime)
           
protected  void closeSocks(java.lang.String finalMsg)
           
 void colorOnlyPrint(java.lang.String msg)
          Lower-Medium-level text output method.
 void colorOnlyPrint(java.lang.String msg, boolean noCache)
          Lower-Medium-level text output method.
 void colorOnlyPrintln(java.lang.String msg)
          Lower-Medium-level text output method.
 void colorOnlyPrintln(java.lang.String msg, boolean noCache)
          Lower-Medium-level text output method.
 int compareTo(CMObject o)
           
protected  void compress2Off()
           
 boolean confirm(java.lang.String Message, java.lang.String Default)
          Prompts the user to enter Y or N, and returns what they enter.
 boolean confirm(java.lang.String Message, java.lang.String Default, long maxTime)
          Prompts the user to enter Y or N, and returns what they enter.
 CMObject copyOf()
          Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.
protected  void doProtocolPings()
           
protected  void errorOut(java.lang.Exception t)
           
 java.lang.String getAddress()
          Gets the current telnet clients ip address.
 java.lang.String getAfkMessage()
          Returns the reason given by the user that they are AFK.
 boolean getClientTelnetMode(int telnetCode)
          Gets a client telnet mode flag.
 java.lang.String[] getColorCodes()
          Returns a list of standard/foreground telnet coded strings indexed by coffeemud color code.
 ColorLibrary.ColorState getCurrentColor()
          Returns the current color code.
 int getGroupID()
          The group identifier for this runnable, which may be used for executor selection
 java.lang.String getGroupName()
          Returns the group name to which this session belongs
 long getIdleMillis()
          Gets the number of milliseconds since a user entry was registered by this session
 long getInputLoopTime()
          Returns the last time in milliseconds that this session began its input loop.
 ColorLibrary.ColorState getLastColor()
          Returns the previous current color code.
 java.util.List<java.lang.String> getLastMsgs()
          Returns a list of the last several message strings received by this user.
 long getLastNPCFight()
          Gets the milliseconds timestamp since this user last registered a npc fight.
 long getLastPKFight()
          Gets the milliseconds timestamp since this user last registered a pk fight.
 long getMillisOnline()
          Gets the milliseconds elapsed since this user came online.
 int getPageBreak()
           
 java.util.List<java.lang.String> getPreviousCMD()
          Returns a pre-parsed, pre-filtered list of strings representing the last command entered by the user through this session.
 int getSaveStatIndex()
          Returns the index into the stat codes array where extra savable fields begins.
 boolean getServerTelnetMode(int telnetCode)
          Gets a server telnet mode flag.
 long getStartTime()
          Either the time this runnable did start running, or will start running, depending on whether it's scheduled
 java.lang.String getStat(java.lang.String code)
          An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders.
 java.lang.String[] getStatCodes()
          Returns an array of the string names of those fields which are modifiable on this object at run-time by builders.
 Session.SessionStatus getStatus()
          Gets the tick/thread status of this session object.
 java.lang.String getTerminalType()
          Gets the terminal type the user has
 long getTotalMillis()
          Gets the total milliseconds consumed by this session objects thread.
 long getTotalTicks()
          Gets the total number of ticks consumed by this session object thread.
 int getWrap()
          Gets the column number for engine word-wrapping.
protected  long getWriteStartTime()
           
 void handleEscape()
           
 void handleIAC()
           
 void handleSubOption(int optionCode, char[] suboptionData, int dataSize)
           
 char hotkey(long maxWait)
          Waits the given milliseconds for a key to be pressed, after which it returns that key, or \0 if nothing pressed.
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 void initializeClass()
          Called ONCE after all objects are loaded, but before the map is read in during initialization.
 void initializeSession(java.net.Socket s, java.lang.String groupName, java.lang.String introTextStr)
          Negotiates various telnet options (or attempts to), and prints the introTextStr to the user.
 void initTelnetMode(int attributesBitmap)
          Initializes a telnet mode between this session and the connected client by negotiating certain fundamental flags, like ANSI, MXP, and MSP.
 boolean isAfk()
          Returns whether this mob/session is currently Away From Keyboard
 boolean isAllowedMcp(java.lang.String packageName, float version)
          Returns true if this client supports the given package at the given version.
 boolean isAllowedMxp(java.lang.String tagString)
          Returns true if the given max tag will be accepted by the client.
 boolean isBeingSnoopedBy(Session S)
          Checks to see if the given session is snooping on this one.
 boolean isFake()
          Returns true if this session is merely a placeholder, and does not represent an actual user connection.
 boolean isLockedUpWriting()
          Checks whether this session is currently over its time limit trying to write data to its socket.
 boolean isPendingLogin(java.lang.String otherLoginName)
          Returns whether this session is engaged in a login/account menu transaction.
 boolean isRunning()
          Whether this session is currently actively interacting with the user in some way -- whether this session currently has "thread time".
 boolean isStat(java.lang.String code)
          An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders.
 boolean isStopped()
          Returns whether this session is done, or slated to be done.
 boolean isWaitingForInput()
          Returns whether this session is waiting for input
 void loginSystem()
           
 void logout(boolean removeMOB)
          Allows the user to select a different character, taking them back to the login prompt, or to the account character listing screen, whichever is appropriate.
 void logoutFinal()
           
 void mainLoop()
           
 MOB mob()
          Returns the player MOB attached to this session object.
 java.lang.String name()
          The displayable name of this object.
 void negotiateTelnetMode(int telnetCode)
          Change telnet mode by negotiating the command to the clients client.
 CMObject newInstance()
          Returns a new instance of this class.
protected  int nonBlockingIn(boolean appendInputFlag)
           
 void onlyPrint(java.lang.String msg)
          Low level text output method.
 void onlyPrint(java.lang.String msg, boolean noCache)
          Low level text output method.
 void print(Physical src, Environmental trg, Environmental tol, java.lang.String msg)
          Medium-level text output method.
 void print(java.lang.String msg)
          Medium-level text output method.
 void println(Physical src, Environmental trg, Environmental tol, java.lang.String msg)
          Medium-level text output method.
 void println(java.lang.String msg)
          Medium-level text output method.
 void prompt(Session.InputCallback callBack)
          Puts the session into an input state, returning immediately.
 java.lang.String prompt(java.lang.String Message)
          Prompts the user to enter a string, and then returns what the enter.
 java.lang.String prompt(java.lang.String Message, long maxTime)
          Prompts the user to enter a string, and then returns what the enter.
 java.lang.String prompt(java.lang.String Message, java.lang.String Default)
          Prompts the user to enter a string, and then returns what the enter.
 java.lang.String prompt(java.lang.String Message, java.lang.String Default, long maxTime)
          Prompts the user to enter a string, and then returns what the enter.
 void promptPrint(java.lang.String msg)
          Medium-level text output method.
 void rawBytesOut(java.io.OutputStream out, byte[] bytes)
           
 void rawCharsOut(char c)
           
 void rawCharsOut(char[] chars)
          Lowest level user-output method.
 void rawCharsOut(java.io.PrintWriter out, char[] chars)
           
 void rawCharsOut(java.lang.String c)
           
 void rawOut(java.lang.String msg)
          Lowest level user-output method.
 void rawPrint(java.lang.String msg)
          Low level line-output method.
 void rawPrintln(java.lang.String msg)
          Low level line-output method.
 int readByte()
           
 int readChar()
           
 java.lang.String readlineContinue()
          Blocks for a short amount of time, returning an input string only if the user happens to have hit enter.
 void run()
           
 void safeRawPrint(java.lang.String msg)
          Low level line-output method.
 void safeRawPrintln(java.lang.String msg)
          Low level line-output method.
 boolean sendGMCPEvent(java.lang.String eventName, java.lang.String json)
          Potentially sends the GMCP event of the given name with the given json doc.
 boolean sendMcpCommand(java.lang.String packageCommand, java.lang.String parms)
          Sends a properly formatted MCP command to the session, if it or its package is supported.
protected  boolean sessionMCPCheck(java.lang.StringBuilder inStr)
           
 void setAccount(PlayerAccount account)
          Sets the player acount attached to this session object.
 void setAfkFlag(boolean truefalse)
          Sets whether this mob/session is currently Away From Keyboard
 void setAFKMessage(java.lang.String str)
          Returns the reason given by the user that they are AFK.
 void setBeingSnoopedBy(Session session, boolean onOff)
          Notifies this session that the given session is snooping it.
 void setClientTelnetMode(int telnetCode, boolean onOff)
          Sets a client telnet mode flag.
 void setCurrentColor(ColorLibrary.ColorState newColor)
          Sets the current color code.
 void setFakeInput(java.lang.String input)
          Send this session fake input as if the user had typed it in.
 void setGroupName(java.lang.String group)
          Sets the group name to which this session belongs
 void setIdleTimers()
          Resets the internal idle timers.
 void setInputLoopTime()
          Sets the last time in milliseconds that this session began its input loop.
 void setKillFlag(boolean truefalse)
           
 void setLastColor(ColorLibrary.ColorState newColor)
          Returns the previous current color code.
 void setLastNPCFight()
          Sets now as the milliseconds timestamp since this user last registered a npc fight.
 void setLastPKFight()
          Sets now as the milliseconds timestamp since this user last registered a pk fight.
protected  boolean setLoggedInState(CharCreationLibrary.LoginResult loginResult)
           
 void setMob(MOB newmob)
          Sets the player MOB attached to this session object.
 void setPreviousCmd(java.util.List<java.lang.String> cmds)
           
 void setPromptFlag(boolean truefalse)
          Notifies this session to output the users prompt again once it has reached a suitable lapse in text output.
 void setServerTelnetMode(int telnetCode, boolean onOff)
          Sets a server telnet mode flag.
 void setStat(java.lang.String code, java.lang.String val)
          An alternative means of setting the values of those fields on this object which are modifiable at run-time by builders.
 void setStatus(Session.SessionStatus newStatus)
          Sets the tick/thread status of this session object.
 void showPrompt()
           
 void snoopSupportPrint(java.lang.String msg, boolean noCache)
           
 int snoopSuspension(int change)
          Increments or decrements the snoop suspension counter by the given amount.
 void stdPrint(Physical src, Environmental trg, Environmental tol, java.lang.String msg)
          Higher-level line output method.
 void stdPrint(java.lang.String msg)
          Higher-level line output method.
 void stdPrintln(Physical src, Environmental trg, Environmental tol, java.lang.String msg)
          Higher-level line output method.
 void stdPrintln(java.lang.String msg)
          Higher-level line output method.
 void stopSession(boolean removeMOB, boolean dropSession, boolean killThread)
          Force the current player to logoff, end the session, and/or kill the thread.
 void wraplessPrint(java.lang.String msg)
          Medium-level text output method.
 void wraplessPrintln(java.lang.String msg)
          Medium-level text output method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOTIMEOUT

protected static final int SOTIMEOUT
See Also:
Constant Field Values

PINGTIMEOUT

protected static final int PINGTIMEOUT
See Also:
Constant Field Values

MSDPPINGINTERVAL

protected static final int MSDPPINGINTERVAL
See Also:
Constant Field Values

PINGCHARS

protected static final char[] PINGCHARS

telnetSupportSet

protected final java.util.Set<java.lang.Integer> telnetSupportSet

mxpSupportSet

protected final java.util.Set<java.lang.String> mxpSupportSet

mxpVersionInfo

protected final java.util.Map<java.lang.String,java.lang.String> mxpVersionInfo

msdpReportables

protected final java.util.Map<java.lang.Object,java.lang.Object> msdpReportables

gmcpSupports

protected final java.util.Map<java.lang.String,java.lang.Double> gmcpSupports

gmcpPings

protected final java.util.Map<java.lang.String,java.lang.Long> gmcpPings

mcpKey

protected final java.lang.String[] mcpKey

mcpKeyPairs

protected final java.util.Map<java.lang.String,java.lang.String> mcpKeyPairs

mcpDisabled

protected final boolean mcpDisabled

mcpSupported

protected final java.util.Map<java.lang.String,float[]> mcpSupported

sockObj

protected final java.util.concurrent.atomic.AtomicBoolean sockObj

groupName

protected java.lang.String groupName

status

protected Session.SessionStatus status

lastStateChangeMs

protected long lastStateChangeMs

snoopSuspensionStack

protected int snoopSuspensionStack

sock

protected java.net.Socket sock

charWriter

protected com.planet_ink.coffee_mud.Common.DefaultSession.SesInputStream charWriter

inMaxBytesPerChar

protected int inMaxBytesPerChar

in

protected java.io.BufferedReader in

out

protected java.io.PrintWriter out

rawin

protected java.io.InputStream rawin

rawout

protected java.io.OutputStream rawout

mob

protected MOB mob

acct

protected PlayerAccount acct

killFlag

protected boolean killFlag

needPrompt

protected boolean needPrompt

afkFlag

protected boolean afkFlag

afkMessage

protected java.lang.String afkMessage

input

protected java.lang.StringBuffer input

fakeInput

protected java.lang.StringBuffer fakeInput

waiting

protected boolean waiting

previousCmd

protected java.util.List<java.lang.String> previousCmd

clookup

protected java.lang.String[] clookup

lastColorStr

protected java.lang.String lastColorStr

lastStr

protected java.lang.String lastStr

spamStack

protected int spamStack

snoops

protected java.util.List<Session> snoops

prevMsgs

protected java.util.List<java.lang.String> prevMsgs

curPrevMsg

protected java.lang.StringBuffer curPrevMsg

lastWasCR

protected boolean lastWasCR

lastWasLF

protected boolean lastWasLF

suspendCommandLine

protected boolean suspendCommandLine

serverTelnetCodes

protected boolean[] serverTelnetCodes

clientTelnetCodes

protected boolean[] clientTelnetCodes

terminalType

protected java.lang.String terminalType

terminalWidth

protected int terminalWidth

terminalHeight

protected int terminalHeight

writeStartTime

protected long writeStartTime

bNextByteIs255

protected boolean bNextByteIs255

connectionComplete

protected boolean connectionComplete

writeLock

protected java.util.concurrent.locks.ReentrantLock writeLock

loginSession

protected CharCreationLibrary.LoginSession loginSession

loggingOutObj

protected boolean[] loggingOutObj

promptSuffix

protected byte[] promptSuffix

currentColor

protected ColorLibrary.ColorState currentColor

lastColor

protected ColorLibrary.ColorState lastColor

lastStart

protected long lastStart

lastStop

protected long lastStop

lastLoopTop

protected long lastLoopTop

nextMsdpPing

protected long nextMsdpPing

userLoginTime

protected long userLoginTime

onlineTime

protected long onlineTime

activeMillis

protected long activeMillis

lastPKFight

protected long lastPKFight

lastNPCFight

protected long lastNPCFight

lastBlahCheck

protected long lastBlahCheck

milliTotal

protected long milliTotal

tickTotal

protected long tickTotal

lastKeystroke

protected long lastKeystroke

lastIACIn

protected long lastIACIn

promptLastShown

protected long promptLastShown

threadGroupChar

protected char threadGroupChar

lastWriteTime

protected volatile long lastWriteTime

debugStrInput

protected boolean debugStrInput

debugBinOutput

protected boolean debugBinOutput

debugBinInput

protected boolean debugBinInput

debugBinInputBuf

protected java.lang.StringBuffer debugBinInputBuf

inputCallback

protected volatile Session.InputCallback inputCallback
Constructor Detail

DefaultSession

public DefaultSession()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, Tech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Returns:
the name of this class

name

public java.lang.String name()
Description copied from interface: CMObject
The displayable name of this object. May be modified by phyStats() object. Is derived from the Name().

Specified by:
name in interface CMObject
Returns:
the modified final name of this object on the map.
See Also:
Environmental.Name()

newInstance

public CMObject newInstance()
Description copied from interface: CMObject
Returns a new instance of this class.

Specified by:
newInstance in interface CMObject
Returns:
a new instance of this class

initializeClass

public void initializeClass()
Description copied from interface: CMObject
Called ONCE after all objects are loaded, but before the map is read in during initialization.

Specified by:
initializeClass in interface CMObject

isFake

public boolean isFake()
Description copied from interface: Session
Returns true if this session is merely a placeholder, and does not represent an actual user connection. Will ensure that the system continues to treat the user as a mob.

Specified by:
isFake in interface Session
Returns:
true if this session is not a connection

copyOf

public CMObject copyOf()
Description copied from interface: CMObject
Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.

Specified by:
copyOf in interface CMObject
Returns:
a clone of this object

compareTo

public int compareTo(CMObject o)
Specified by:
compareTo in interface java.lang.Comparable<CMObject>

setStatus

public void setStatus(Session.SessionStatus newStatus)
Description copied from interface: Session
Sets the tick/thread status of this session object.

Specified by:
setStatus in interface Session
Parameters:
newStatus - the tick status
See Also:
Session.SessionStatus

getStartTime

public long getStartTime()
Description copied from interface: CMRunnable
Either the time this runnable did start running, or will start running, depending on whether it's scheduled

Specified by:
getStartTime in interface CMRunnable
Returns:
the time in millis

getGroupID

public int getGroupID()
Description copied from interface: CMRunnable
The group identifier for this runnable, which may be used for executor selection

Specified by:
getGroupID in interface CMRunnable
Returns:
the identifier for this runnable

isAllowedMcp

public boolean isAllowedMcp(java.lang.String packageName,
                            float version)
Description copied from interface: Session
Returns true if this client supports the given package at the given version.

Specified by:
isAllowedMcp in interface Session
Parameters:
packageName - the package to check
version - the version of the package to check
Returns:
true if there's support, false otherwise

sendMcpCommand

public boolean sendMcpCommand(java.lang.String packageCommand,
                              java.lang.String parms)
Description copied from interface: Session
Sends a properly formatted MCP command to the session, if it or its package is supported.

Specified by:
sendMcpCommand in interface Session
Parameters:
packageCommand - the fully formed command
parms - the variable parameters, already well formed
Returns:
true if it was sent, false otherwise

initializeSession

public void initializeSession(java.net.Socket s,
                              java.lang.String groupName,
                              java.lang.String introTextStr)
Description copied from interface: Session
Negotiates various telnet options (or attempts to), and prints the introTextStr to the user.

Specified by:
initializeSession in interface Session
Parameters:
s - the socket the user connected from
groupName - the name of the thread group the session goes to
introTextStr - introductory text string (Hello!)

compress2Off

protected void compress2Off()
                     throws java.io.IOException
Throws:
java.io.IOException

getGroupName

public java.lang.String getGroupName()
Description copied from interface: Session
Returns the group name to which this session belongs

Specified by:
getGroupName in interface Session
Returns:
the thread group name

setGroupName

public void setGroupName(java.lang.String group)
Description copied from interface: Session
Sets the group name to which this session belongs

Specified by:
setGroupName in interface Session
Parameters:
group - the thread group name

setFakeInput

public void setFakeInput(java.lang.String input)
Description copied from interface: Session
Send this session fake input as if the user had typed it in.

Specified by:
setFakeInput in interface Session
Parameters:
input - text to send.

setServerTelnetMode

public void setServerTelnetMode(int telnetCode,
                                boolean onOff)
Description copied from interface: Session
Sets a server telnet mode flag.

Specified by:
setServerTelnetMode in interface Session
Parameters:
telnetCode - the telnet code
onOff - true to turn on, false to turn off the flag
See Also:
Session.TELNET_ANSI, Session.getServerTelnetMode(int)

getServerTelnetMode

public boolean getServerTelnetMode(int telnetCode)
Description copied from interface: Session
Gets a server telnet mode flag.

Specified by:
getServerTelnetMode in interface Session
Parameters:
telnetCode - the telnet code
Returns:
true, if server telnet mode is on, false otherwise
See Also:
Session.TELNET_ANSI, Session.setServerTelnetMode(int, boolean)

setClientTelnetMode

public void setClientTelnetMode(int telnetCode,
                                boolean onOff)
Description copied from interface: Session
Sets a client telnet mode flag.

Specified by:
setClientTelnetMode in interface Session
Parameters:
telnetCode - the telnet code
onOff - true to turn on, false to turn off the flag
See Also:
Session.TELNET_ANSI, Session.getClientTelnetMode(int)

getClientTelnetMode

public boolean getClientTelnetMode(int telnetCode)
Description copied from interface: Session
Gets a client telnet mode flag.

Specified by:
getClientTelnetMode in interface Session
Parameters:
telnetCode - the telnet code
Returns:
true, if client telnet mode is on, false otherwise
See Also:
Session.TELNET_ANSI, Session.setClientTelnetMode(int, boolean)

isAllowedMxp

public boolean isAllowedMxp(java.lang.String tagString)
Description copied from interface: Session
Returns true if the given max tag will be accepted by the client.

Specified by:
isAllowedMxp in interface Session
Parameters:
tagString - the tag to check
Returns:
true if allowed, false otherwise

sendGMCPEvent

public boolean sendGMCPEvent(java.lang.String eventName,
                             java.lang.String json)
Description copied from interface: Session
Potentially sends the GMCP event of the given name with the given json doc.

Specified by:
sendGMCPEvent in interface Session
Parameters:
eventName - the event name, like comm.channel
json - the json doc, like {"blah":"BLAH"}
Returns:
true if GMCP was enabled for this session, false otherwise

changeTelnetMode

public void changeTelnetMode(int telnetCode,
                             boolean onOff)
Description copied from interface: Session
Change telnet mode by sending the appropriate command to the clients client. A response received later will trigger mode changed.

Specified by:
changeTelnetMode in interface Session
Parameters:
telnetCode - the telnet code
onOff - true to turn on, false to turn off the flag
See Also:
Session.TELNET_ANSI, Session.setClientTelnetMode(int, boolean), Session.setServerTelnetMode(int, boolean)

changeTelnetModeBackwards

public void changeTelnetModeBackwards(int telnetCode,
                                      boolean onOff)
                               throws java.io.IOException
Throws:
java.io.IOException

changeTelnetModeBackwards

public void changeTelnetModeBackwards(java.io.OutputStream out,
                                      int telnetCode,
                                      boolean onOff)
                               throws java.io.IOException
Throws:
java.io.IOException

negotiateTelnetMode

public void negotiateTelnetMode(int telnetCode)
Description copied from interface: Session
Change telnet mode by negotiating the command to the clients client.

Specified by:
negotiateTelnetMode in interface Session
Parameters:
telnetCode - the telnet code
See Also:
Session.TELNET_ANSI, Session.setClientTelnetMode(int, boolean), Session.setServerTelnetMode(int, boolean)

initTelnetMode

public void initTelnetMode(int attributesBitmap)
Description copied from interface: Session
Initializes a telnet mode between this session and the connected client by negotiating certain fundamental flags, like ANSI, MXP, and MSP. It will use a bitmap of MOB flags passed in as a guide.

Specified by:
initTelnetMode in interface Session
Parameters:
attributesBitmap - the mobbitmap the bitmap of mob flags to use as a guide in negotiation
See Also:
MOB.getAttributesBitmap(), MOB.Attrib, Session.changeTelnetMode(int, boolean)

getCurrentColor

public ColorLibrary.ColorState getCurrentColor()
Description copied from interface: Session
Returns the current color code.

Specified by:
getCurrentColor in interface Session
Returns:
the current color code.

setCurrentColor

public void setCurrentColor(ColorLibrary.ColorState newColor)
Description copied from interface: Session
Sets the current color code.

Specified by:
setCurrentColor in interface Session
Parameters:
newColor - the color to change it to

getLastColor

public ColorLibrary.ColorState getLastColor()
Description copied from interface: Session
Returns the previous current color code.

Specified by:
getLastColor in interface Session
Returns:
the previous current color code.

setLastColor

public void setLastColor(ColorLibrary.ColorState newColor)
Description copied from interface: Session
Returns the previous current color code.

Specified by:
setLastColor in interface Session
Parameters:
newColor - the color to change it to

getTotalMillis

public long getTotalMillis()
Description copied from interface: Session
Gets the total milliseconds consumed by this session objects thread.

Specified by:
getTotalMillis in interface Session
Returns:
the total milliseconds consumed

getIdleMillis

public long getIdleMillis()
Description copied from interface: Session
Gets the number of milliseconds since a user entry was registered by this session

Specified by:
getIdleMillis in interface Session
Returns:
the idle milliseconds passed
See Also:
Session.setIdleTimers()

getTotalTicks

public long getTotalTicks()
Description copied from interface: Session
Gets the total number of ticks consumed by this session object thread.

Specified by:
getTotalTicks in interface Session
Returns:
the total ticks consumed

getMillisOnline

public long getMillisOnline()
Description copied from interface: Session
Gets the milliseconds elapsed since this user came online.

Specified by:
getMillisOnline in interface Session
Returns:
the milliseconds online

getInputLoopTime

public long getInputLoopTime()
Description copied from interface: Session
Returns the last time in milliseconds that this session began its input loop. Is typically only held up by executing a user command, so it is an accurate gauge of a locked up user command.

Specified by:
getInputLoopTime in interface Session
Returns:
the last time in milliseconds that this session began its input loop
See Also:
Session.setInputLoopTime()

setInputLoopTime

public void setInputLoopTime()
Description copied from interface: Session
Sets the last time in milliseconds that this session began its input loop. Is typically only held up by executing a user command, so it is an accurate gauge of a locked up user command.

Specified by:
setInputLoopTime in interface Session
See Also:
Session.getInputLoopTime()

getLastPKFight

public long getLastPKFight()
Description copied from interface: Session
Gets the milliseconds timestamp since this user last registered a pk fight.

Specified by:
getLastPKFight in interface Session
Returns:
the last pk fight timestamp
See Also:
Session.setLastPKFight(), Session.setLastNPCFight()

setLastPKFight

public void setLastPKFight()
Description copied from interface: Session
Sets now as the milliseconds timestamp since this user last registered a pk fight.

Specified by:
setLastPKFight in interface Session
See Also:
Session.getLastPKFight(), Session.getLastNPCFight()

getLastNPCFight

public long getLastNPCFight()
Description copied from interface: Session
Gets the milliseconds timestamp since this user last registered a npc fight.

Specified by:
getLastNPCFight in interface Session
Returns:
the last npc fight timestamp
See Also:
Session.setLastPKFight(), Session.setLastNPCFight()

setLastNPCFight

public void setLastNPCFight()
Description copied from interface: Session
Sets now as the milliseconds timestamp since this user last registered a npc fight.

Specified by:
setLastNPCFight in interface Session
See Also:
Session.getLastPKFight(), Session.getLastNPCFight()

getLastMsgs

public java.util.List<java.lang.String> getLastMsgs()
Description copied from interface: Session
Returns a list of the last several message strings received by this user. All are already previously filtered and parsed and ready to display.

Specified by:
getLastMsgs in interface Session
Returns:
a list of string message strings

getTerminalType

public java.lang.String getTerminalType()
Description copied from interface: Session
Gets the terminal type the user has

Specified by:
getTerminalType in interface Session
Returns:
the terminal type

mob

public MOB mob()
Description copied from interface: Session
Returns the player MOB attached to this session object.

Specified by:
mob in interface Session
Returns:
the player MOB attached to this session object.
See Also:
Session.setMob(MOB)

setMob

public void setMob(MOB newmob)
Description copied from interface: Session
Sets the player MOB attached to this session object.

Specified by:
setMob in interface Session
Parameters:
newmob - the player MOB attached to this session object.
See Also:
Session.mob()

setAccount

public void setAccount(PlayerAccount account)
Description copied from interface: Session
Sets the player acount attached to this session object.

Specified by:
setAccount in interface Session
Parameters:
account - the player account attached to this session object.
See Also:
Session.mob()

getWrap

public int getWrap()
Description copied from interface: Session
Gets the column number for engine word-wrapping. 0 Means disabled.

Specified by:
getWrap in interface Session
Returns:
the wrap column

getPageBreak

public int getPageBreak()

isStopped

public boolean isStopped()
Description copied from interface: Session
Returns whether this session is done, or slated to be done.

Specified by:
isStopped in interface Session
Returns:
true if this session needs to go, false otherwise
See Also:
Session.logout(boolean), Session.isStopped()

setKillFlag

public void setKillFlag(boolean truefalse)

getPreviousCMD

public java.util.List<java.lang.String> getPreviousCMD()
Description copied from interface: Session
Returns a pre-parsed, pre-filtered list of strings representing the last command entered by the user through this session.

Specified by:
getPreviousCMD in interface Session
Returns:
a list of strings

setBeingSnoopedBy

public void setBeingSnoopedBy(Session session,
                              boolean onOff)
Description copied from interface: Session
Notifies this session that the given session is snooping it. This session will manage said snooping.

Specified by:
setBeingSnoopedBy in interface Session
Parameters:
session - the session to snoop on me.
onOff - true to turn on snooping, false otherwise
See Also:
Session.setBeingSnoopedBy(Session, boolean), Session.isBeingSnoopedBy(Session), Session.snoopSuspension(int)

isBeingSnoopedBy

public boolean isBeingSnoopedBy(Session S)
Description copied from interface: Session
Checks to see if the given session is snooping on this one.

Specified by:
isBeingSnoopedBy in interface Session
Parameters:
S - the session to check for a snoop on me.
Returns:
true if the given session is snooping on me, false otherwise
See Also:
Session.setBeingSnoopedBy(Session, boolean), Session.isBeingSnoopedBy(Session), Session.snoopSuspension(int)

snoopSuspension

public int snoopSuspension(int change)
Description copied from interface: Session
Increments or decrements the snoop suspension counter by the given amount. Only when the counter is 0 does snooping of this session actually occur.

Specified by:
snoopSuspension in interface Session
Parameters:
change - the amount to change the snoop suspension counter by
Returns:
the current value of the snoop suspension counter after the change
See Also:
Session.setBeingSnoopedBy(Session, boolean), Session.isBeingSnoopedBy(Session), Session.snoopSuspension(int)

setPreviousCmd

public void setPreviousCmd(java.util.List<java.lang.String> cmds)

isAfk

public boolean isAfk()
Description copied from interface: Session
Returns whether this mob/session is currently Away From Keyboard

Specified by:
isAfk in interface Session
Returns:
true if they are AFK, false otherwise
See Also:
Session.setAfkFlag(boolean), Session.setAFKMessage(String)

setAfkFlag

public void setAfkFlag(boolean truefalse)
Description copied from interface: Session
Sets whether this mob/session is currently Away From Keyboard

Specified by:
setAfkFlag in interface Session
Parameters:
truefalse - true if they are AFK, false otherwise
See Also:
Session.isAfk(), Session.getAfkMessage()

getAfkMessage

public java.lang.String getAfkMessage()
Description copied from interface: Session
Returns the reason given by the user that they are AFK.

Specified by:
getAfkMessage in interface Session
Returns:
the reason given by the user that they are AFK.
See Also:
Session.setAfkFlag(boolean), Session.setAFKMessage(String)

setAFKMessage

public void setAFKMessage(java.lang.String str)
Description copied from interface: Session
Returns the reason given by the user that they are AFK.

Specified by:
setAFKMessage in interface Session
Parameters:
str - the reason given by the user that they are AFK.
See Also:
Session.setAfkFlag(boolean), Session.getAfkMessage()

errorOut

protected void errorOut(java.lang.Exception t)

getWriteStartTime

protected long getWriteStartTime()

isLockedUpWriting

public boolean isLockedUpWriting()
Description copied from interface: Session
Checks whether this session is currently over its time limit trying to write data to its socket. For some reason this happens, and this method detects it.

Specified by:
isLockedUpWriting in interface Session
Returns:
true if something bas happened, false otherwise

rawBytesOut

public final void rawBytesOut(java.io.OutputStream out,
                              byte[] bytes)
                       throws java.io.IOException
Throws:
java.io.IOException

rawCharsOut

public void rawCharsOut(char[] chars)
Description copied from interface: Session
Lowest level user-output method. Does nothing but send the string to the user, period.

Specified by:
rawCharsOut in interface Session
Parameters:
chars - string (as char array) to send out to the user

rawCharsOut

public void rawCharsOut(java.io.PrintWriter out,
                        char[] chars)

rawCharsOut

public void rawCharsOut(java.lang.String c)

rawCharsOut

public void rawCharsOut(char c)

snoopSupportPrint

public void snoopSupportPrint(java.lang.String msg,
                              boolean noCache)

onlyPrint

public void onlyPrint(java.lang.String msg)
Description copied from interface: Session
Low level text output method. Implements such features as snoops, spam-stacking. No page breaking, and Always line caching

Specified by:
onlyPrint in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

onlyPrint

public void onlyPrint(java.lang.String msg,
                      boolean noCache)
Description copied from interface: Session
Low level text output method. Implements such features as snoops, spam-stacking, page breaks, and line caching

Specified by:
onlyPrint in interface Session
Parameters:
msg - the string to send to the user
noCache - true to disable line caching, false otherwise
See Also:
Session.rawCharsOut(char[])

rawOut

public void rawOut(java.lang.String msg)
Description copied from interface: Session
Lowest level user-output method. Does nothing but send the string to the user, period.

Specified by:
rawOut in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.rawCharsOut(char[])

rawPrint

public void rawPrint(java.lang.String msg)
Description copied from interface: Session
Low level line-output method. Sets the prompt flag after write, and inserts additional pre-linefeed if currently at the prompt.

Specified by:
rawPrint in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.rawPrint(String)

safeRawPrint

public void safeRawPrint(java.lang.String msg)
Description copied from interface: Session
Low level line-output method. Sets the prompt flag after write, and inserts additional pre-linefeed if currently at the prompt. Does not do color, but does protect mxp clients.

Specified by:
safeRawPrint in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.safeRawPrintln(String)

print

public void print(java.lang.String msg)
Description copied from interface: Session
Medium-level text output method. Does full filtering of special characters and codes. Does not manage the prompt, and should NOT be used for prompts.

Specified by:
print in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean), Session.promptPrint(String)

promptPrint

public void promptPrint(java.lang.String msg)
Description copied from interface: Session
Medium-level text output method. Does full filtering of special characters and codes. Does not manage the prompt. Should be used for prompts!

Specified by:
promptPrint in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

rawPrintln

public void rawPrintln(java.lang.String msg)
Description copied from interface: Session
Low level line-output method. Sets the prompt flag after write, and inserts additional pre-linefeed if currently at the prompt. Adds post linefeed of course. Does not do a page break.

Specified by:
rawPrintln in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.rawPrintln(String)

safeRawPrintln

public void safeRawPrintln(java.lang.String msg)
Description copied from interface: Session
Low level line-output method. Sets the prompt flag after write, and inserts additional pre-linefeed if currently at the prompt. Adds post linefeed of course. Does not do a page break, or color, but does protect mxp clients.

Specified by:
safeRawPrintln in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.safeRawPrint(String)

stdPrint

public void stdPrint(java.lang.String msg)
Description copied from interface: Session
Higher-level line output method. Does full filtering of special characters and codes.

Specified by:
stdPrint in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.rawPrint(String)

print

public void print(Physical src,
                  Environmental trg,
                  Environmental tol,
                  java.lang.String msg)
Description copied from interface: Session
Medium-level text output method. Does full filtering of special characters and codes using given variable values. Does not manage the prompt.

Specified by:
print in interface Session
Parameters:
src - variable for special code parsing: Source
trg - variable for special code parsing: Target
tol - variable for special code parsing: Tool
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

stdPrint

public void stdPrint(Physical src,
                     Environmental trg,
                     Environmental tol,
                     java.lang.String msg)
Description copied from interface: Session
Higher-level line output method. Does full filtering of special characters and codes using given variable values.

Specified by:
stdPrint in interface Session
Parameters:
src - variable for special code parsing: Source
trg - variable for special code parsing: Target
tol - variable for special code parsing: Tool
msg - the string to send to the user
See Also:
Session.rawPrint(String)

println

public void println(java.lang.String msg)
Description copied from interface: Session
Medium-level text output method. Does full filtering of special characters and codes. Does not manage the prompt. Adds a linefeed at the end though.

Specified by:
println in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

wraplessPrintln

public void wraplessPrintln(java.lang.String msg)
Description copied from interface: Session
Medium-level text output method. Does full filtering of special characters and codes. DOES manage the prompt, but turns OFF word wrap! Adds a linefeed at the end.

Specified by:
wraplessPrintln in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

wraplessPrint

public void wraplessPrint(java.lang.String msg)
Description copied from interface: Session
Medium-level text output method. Does full filtering of special characters and codes. DOES manage the prompt, but turns OFF word wrap!

Specified by:
wraplessPrint in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

colorOnlyPrintln

public void colorOnlyPrintln(java.lang.String msg)
Description copied from interface: Session
Lower-Medium-level text output method. Does only the parsing of color codes, no word wrapping, no codes. Adds a linefeed at the end.

Specified by:
colorOnlyPrintln in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

colorOnlyPrintln

public void colorOnlyPrintln(java.lang.String msg,
                             boolean noCache)
Description copied from interface: Session
Lower-Medium-level text output method. Does only the parsing of color codes, no word wrapping, no codes. Adds a linefeed at the end.

Specified by:
colorOnlyPrintln in interface Session
Parameters:
msg - the string to send to the user
noCache - true to disable line caching, false otherwise
See Also:
Session.onlyPrint(String, boolean)

colorOnlyPrint

public void colorOnlyPrint(java.lang.String msg)
Description copied from interface: Session
Lower-Medium-level text output method. Does only the parsing of color codes, no word wrapping, no codes.

Specified by:
colorOnlyPrint in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

colorOnlyPrint

public void colorOnlyPrint(java.lang.String msg,
                           boolean noCache)
Description copied from interface: Session
Lower-Medium-level text output method. Does only the parsing of color codes, no word wrapping, no codes.

Specified by:
colorOnlyPrint in interface Session
Parameters:
msg - the string to send to the user
noCache - true to disable line caching, false otherwise
See Also:
Session.onlyPrint(String, boolean)

stdPrintln

public void stdPrintln(java.lang.String msg)
Description copied from interface: Session
Higher-level line output method. Does full filtering of special characters and codes.

Specified by:
stdPrintln in interface Session
Parameters:
msg - the string to send to the user
See Also:
Session.rawPrintln(String)

println

public void println(Physical src,
                    Environmental trg,
                    Environmental tol,
                    java.lang.String msg)
Description copied from interface: Session
Medium-level text output method. Does full filtering of special characters and codes using given variable values. Does not manage the prompt. Adds a linefeed at the end though.

Specified by:
println in interface Session
Parameters:
src - variable for special code parsing: Source
trg - variable for special code parsing: Target
tol - variable for special code parsing: Tool
msg - the string to send to the user
See Also:
Session.onlyPrint(String, boolean)

stdPrintln

public void stdPrintln(Physical src,
                       Environmental trg,
                       Environmental tol,
                       java.lang.String msg)
Description copied from interface: Session
Higher-level line output method. Does full filtering of special characters and codes using given variable values.

Specified by:
stdPrintln in interface Session
Parameters:
src - variable for special code parsing: Source
trg - variable for special code parsing: Target
tol - variable for special code parsing: Tool
msg - the string to send to the user
See Also:
Session.rawPrintln(String)

setPromptFlag

public void setPromptFlag(boolean truefalse)
Description copied from interface: Session
Notifies this session to output the users prompt again once it has reached a suitable lapse in text output.

Specified by:
setPromptFlag in interface Session
Parameters:
truefalse - true to send another prompt, false otherwise

prompt

public java.lang.String prompt(java.lang.String Message,
                               java.lang.String Default,
                               long maxTime)
                        throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter a string, and then returns what the enter. Possibly times out, and may throw an exception on disconnnect or time out.

Specified by:
prompt in interface Session
Parameters:
Message - the prompt message to display to the user
Default - the default response if the user just hits enter
maxTime - max number of milliseconds to wait before timing out
Returns:
the string entered by the user, or the Default
Throws:
java.io.IOException - a disconnect or time out
See Also:
Session.prompt(String), Session.prompt(String, String), Session.prompt(String, long)

prompt

public java.lang.String prompt(java.lang.String Message,
                               java.lang.String Default)
                        throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter a string, and then returns what the enter. Does not time out, but may throw an exception on disconnnect.

Specified by:
prompt in interface Session
Parameters:
Message - the prompt message to display to the user
Default - the default response if the user just hits enter
Returns:
the string entered by the user, or the Default
Throws:
java.io.IOException - a disconnect
See Also:
Session.prompt(String), Session.prompt(String, long), Session.prompt(String, String, long)

prompt

public void prompt(Session.InputCallback callBack)
Description copied from interface: Session
Puts the session into an input state, returning immediately. The given callback will be made when the ENTER key has been hit, and the session will go back into a prompt state. This is basically for non-blocking input.

Specified by:
prompt in interface Session
Parameters:
callBack - the callback to modify and make when done
See Also:
Session.InputCallback

prompt

public java.lang.String prompt(java.lang.String Message,
                               long maxTime)
                        throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter a string, and then returns what the enter. Possibly times out, and may throw an exception on disconnnect or time out.

Specified by:
prompt in interface Session
Parameters:
Message - the prompt message to display to the user
maxTime - max number of milliseconds to wait before timing out
Returns:
the string entered by the user
Throws:
java.io.IOException - a disconnect or time out
See Also:
Session.prompt(String), Session.prompt(String, String), Session.prompt(String, String, long)

prompt

public java.lang.String prompt(java.lang.String Message)
                        throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter a string, and then returns what the enter. Does not time out, but may throw an exception on disconnnect.

Specified by:
prompt in interface Session
Parameters:
Message - the prompt message to display to the user
Returns:
the string entered by the user
Throws:
java.io.IOException - a disconnect
See Also:
Session.prompt(String, String), Session.prompt(String, long), Session.prompt(String, String, long)

getColorCodes

public java.lang.String[] getColorCodes()
Description copied from interface: Session
Returns a list of standard/foreground telnet coded strings indexed by coffeemud color code. May be from the standard list, or read from player records for a customized list.

Specified by:
getColorCodes in interface Session
Returns:
telnet coded color strings.

handleSubOption

public void handleSubOption(int optionCode,
                            char[] suboptionData,
                            int dataSize)
                     throws java.io.IOException
Throws:
java.io.IOException

handleEscape

public void handleEscape()
                  throws java.io.IOException,
                         java.io.InterruptedIOException
Throws:
java.io.IOException
java.io.InterruptedIOException

handleIAC

public void handleIAC()
               throws java.io.IOException,
                      java.io.InterruptedIOException
Throws:
java.io.IOException
java.io.InterruptedIOException

readByte

public int readByte()
             throws java.io.IOException
Throws:
java.io.IOException

readChar

public int readChar()
             throws java.io.IOException
Throws:
java.io.IOException

hotkey

public char hotkey(long maxWait)
Description copied from interface: Session
Waits the given milliseconds for a key to be pressed, after which it returns that key, or \0 if nothing pressed.

Specified by:
hotkey in interface Session
Parameters:
maxWait - the maximum milliseconds to wait
Returns:
the key pressed, or \0

nonBlockingIn

protected int nonBlockingIn(boolean appendInputFlag)
                     throws java.io.IOException
Throws:
java.io.IOException

clearInputBuffer

protected void clearInputBuffer(long maxTime)

blockingIn

public java.lang.String blockingIn(long maxTime,
                                   boolean filter)
                            throws java.io.IOException
Description copied from interface: Session
Blocks the current thread until the user attached to this session hits ENTER, returning the characters they enter. Completely filtered input.

Specified by:
blockingIn in interface Session
Parameters:
maxTime - milliseconds before InterruptedIOException thrown
filter - true to allow normal coffeemud input filtering
Returns:
the string entered by the user
Throws:
java.io.IOException - any exception generated during input

blockingIn

public java.lang.String blockingIn()
                            throws java.io.IOException
Throws:
java.io.IOException

sessionMCPCheck

protected boolean sessionMCPCheck(java.lang.StringBuilder inStr)

readlineContinue

public java.lang.String readlineContinue()
                                  throws java.io.IOException,
                                         java.net.SocketException
Description copied from interface: Session
Blocks for a short amount of time, returning an input string only if the user happens to have hit enter.

Specified by:
readlineContinue in interface Session
Returns:
a string entered by the user
Throws:
java.io.IOException - exceptions thrown, typically a timeout
java.net.SocketException - exceptions thrown, typically socket error

confirm

public boolean confirm(java.lang.String Message,
                       java.lang.String Default,
                       long maxTime)
                throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter Y or N, and returns what they enter. Possibly times out, and may throw an exception on disconnnect or time out.

Specified by:
confirm in interface Session
Parameters:
Message - the prompt message to display to the user
Default - the default response if the user just hits enter
maxTime - max number of milliseconds to wait before timing out
Returns:
true if they entered Y, false otherwise
Throws:
java.io.IOException - a disconnect or time out
See Also:
Session.confirm(String, String)

confirm

public boolean confirm(java.lang.String Message,
                       java.lang.String Default)
                throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter Y or N, and returns what they enter. Will not time out, but may throw an exception on disconnect.

Specified by:
confirm in interface Session
Parameters:
Message - the prompt message to display to the user
Default - the default response if the user just hits enter
Returns:
true if they entered Y, false otherwise
Throws:
java.io.IOException - a disconnect
See Also:
Session.confirm(String, String, long)

choose

public java.lang.String choose(java.lang.String Message,
                               java.lang.String Choices,
                               java.lang.String Default)
                        throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter one character responses from a set of valid choices. Repeats the prompt if the user does not enter a valid choice. ENTER is a valid choice for Default. Does not time out, but may throw an exception on disconnnect.

Specified by:
choose in interface Session
Parameters:
Message - the prompt message to display to the user
Choices - a list of uppercase characters that may be entered
Default - the default response if the user just hits enter
Returns:
the character entered from the choices
Throws:
java.io.IOException - a disconnect
See Also:
Session.choose(String, String, String, long)

choose

public java.lang.String choose(java.lang.String Message,
                               java.lang.String Choices,
                               java.lang.String Default,
                               long maxTime)
                        throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter one character responses from a set of valid choices. Repeats the prompt if the user does not enter a valid choice. ENTER is a valid choice for Default. May time out, and may throw an exception on disconnnect.

Specified by:
choose in interface Session
Parameters:
Message - the prompt message to display to the user
Choices - a list of uppercase characters that may be entered
Default - the default response if the user just hits enter
maxTime - max number of milliseconds to wait before timing out
Returns:
the character entered from the choices
Throws:
java.io.IOException - a disconnect or time out
See Also:
Session.choose(String, String, String)

choose

public java.lang.String choose(java.lang.String Message,
                               java.lang.String Choices,
                               java.lang.String Default,
                               long maxTime,
                               java.util.List<java.lang.String> paramsOut)
                        throws java.io.IOException
Description copied from interface: Session
Prompts the user to enter one character responses from a set of valid choices. Repeats the prompt if the user does not enter a valid choice. ENTER is a valid choice for Default. Does not time out, but may throw an exception on disconnnect.

Specified by:
choose in interface Session
Parameters:
Message - the prompt message to display to the user
Choices - a list of uppercase characters that may be entered
Default - the default response if the user just hits enter
maxTime - max number of milliseconds to wait before timing out
paramsOut - an empty list to put any extra crap added to the end of the choice.
Returns:
the character entered from the choices
Throws:
java.io.IOException - a disconnect
See Also:
Session.choose(String, String, String, long)

stopSession

public void stopSession(boolean removeMOB,
                        boolean dropSession,
                        boolean killThread)
Description copied from interface: Session
Force the current player to logoff, end the session, and/or kill the thread.

Specified by:
stopSession in interface Session
Parameters:
removeMOB - true to remove the mob from the game
dropSession - true to force closed sockets, and removed session
killThread - true to force a thread death, and false to be more lenient
See Also:
Session.isStopped()

showPrompt

public void showPrompt()

closeSocks

protected void closeSocks(java.lang.String finalMsg)

getAddress

public java.lang.String getAddress()
Description copied from interface: Session
Gets the current telnet clients ip address.

Specified by:
getAddress in interface Session
Returns:
the ip address

getStatus

public Session.SessionStatus getStatus()
Description copied from interface: Session
Gets the tick/thread status of this session object.

Specified by:
getStatus in interface Session
Returns:
the tick status
See Also:
Session.SessionStatus

isWaitingForInput

public boolean isWaitingForInput()
Description copied from interface: Session
Returns whether this session is waiting for input

Specified by:
isWaitingForInput in interface Session
Returns:
true if it is, false otherwise

logout

public void logout(boolean removeMOB)
Description copied from interface: Session
Allows the user to select a different character, taking them back to the login prompt, or to the account character listing screen, whichever is appropriate.

Specified by:
logout in interface Session
Parameters:
removeMOB - true to remove the mob from the game

isRunning

public boolean isRunning()
Description copied from interface: Session
Whether this session is currently actively interacting with the user in some way -- whether this session currently has "thread time".

Specified by:
isRunning in interface Session
Returns:
true if its active and running, false otherwise

isPendingLogin

public boolean isPendingLogin(java.lang.String otherLoginName)
Description copied from interface: Session
Returns whether this session is engaged in a login/account menu transaction. If a loginsession is passed it, it will return true only if the two sessions are engaging the same login name.

Specified by:
isPendingLogin in interface Session
Parameters:
otherLoginName - another login name potentially match
Returns:
true if it is pending, false otherwise

doProtocolPings

protected void doProtocolPings()

run

public void run()
Specified by:
run in interface java.lang.Runnable

autoLogin

public boolean autoLogin(java.lang.String name,
                         java.lang.String password)
Description copied from interface: Session
If the session is in a non-logged in state (or even if it is), this will automatically login the user with the given name and password, and switch the session to the main loop. Sending null for name/password will reset the login session.

Specified by:
autoLogin in interface Session
Parameters:
name - the username
password - the password
Returns:
true if the login succeeded

setLoggedInState

protected boolean setLoggedInState(CharCreationLibrary.LoginResult loginResult)

loginSystem

public void loginSystem()

logoutFinal

public void logoutFinal()

mainLoop

public void mainLoop()

activeTimeMillis

public long activeTimeMillis()
Description copied from interface: CMRunnable
Returns the number of milliseconds this runnable has been running.

Specified by:
activeTimeMillis in interface CMRunnable
Returns:
the time in millis

setIdleTimers

public void setIdleTimers()
Description copied from interface: Session
Resets the internal idle timers.

Specified by:
setIdleTimers in interface Session
See Also:
Session.getIdleMillis()

getSaveStatIndex

public int getSaveStatIndex()
Description copied from interface: Modifiable
Returns the index into the stat codes array where extra savable fields begins. This number is always the same as getStatCodes().length unless there are extra fields which need to be saved in xml for generic objects. This method is used by editors for post-build user-defined fields.

Specified by:
getSaveStatIndex in interface Modifiable
Returns:
the index into getStatCodes()
See Also:
Modifiable.getStatCodes(), Modifiable.getStat(String), Modifiable.setStat(String, String)

getStatCodes

public java.lang.String[] getStatCodes()
Description copied from interface: Modifiable
Returns an array of the string names of those fields which are modifiable on this object at run-time by builders.

Specified by:
getStatCodes in interface Modifiable
Returns:
list of the fields which may be set.
See Also:
Modifiable.getStat(String), Modifiable.setStat(String, String)

isStat

public boolean isStat(java.lang.String code)
Description copied from interface: Modifiable
An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. Values returned are always strings, even if the field itself is numeric or a list.

Specified by:
isStat in interface Modifiable
Parameters:
code - the name of the field to read.
Returns:
true if the code is a real value, false otherwise
See Also:
Modifiable.getStatCodes()

getStat

public java.lang.String getStat(java.lang.String code)
Description copied from interface: Modifiable
An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. Values returned are always strings, even if the field itself is numeric or a list.

Specified by:
getStat in interface Modifiable
Parameters:
code - the name of the field to read.
Returns:
the value of the field read
See Also:
Modifiable.getStatCodes()

setStat

public void setStat(java.lang.String code,
                    java.lang.String val)
Description copied from interface: Modifiable
An alternative means of setting the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. The value passed in is always a string, even if the field itself is numeric or a list.

Specified by:
setStat in interface Modifiable
Parameters:
code - the name of the field to set
val - the value to set the field to
See Also:
Modifiable.getStatCodes()