All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class key.TelnetConnection

java.lang.Object
   |
   +----key.Atom
           |
           +----key.InteractiveConnection
                   |
                   +----key.TelnetConnection

public class TelnetConnection
extends InteractiveConnection
Works closely with the 'Terminal' class to achieve different terminal emulations Implements RFCs: 1091, 858, 857, 854, 885, 1143, 855, 1073


Variable Index

 o canPageEver
 o CRLF
 o DEFAULT_HEIGHT
 o DEFAULT_WIDTH
 o INPUT_BUFFER
 o MAX_OVERRUN
 o PAGER_LACKS_PAGES
 o PAGER_THRESHOLD
The number of lines less than the terminal height which is the border between paging and not paging
 o PAGER_VERTICAL_SPACE
The amount of additional space the pager reserves at the bottom of the screen.
 o SMALLEST_BELIEVABLE_HEIGHT
 o SMALLEST_BELIEVABLE_WIDTH

Constructor Index

 o TelnetConnection(Socket)
Constructor

Method Index

 o blankLine()
leave some blank space (usually the height of the characters
 o canPage()
 o check()
This function will be called every 'now and again', as a 'check' function when no input is required (we're not waiting), but some is allowed.
 o dashes(int)
Returns a string of the specified number of dashes

This routine has been optimised for up to 70 spaces, requesting more than this will slow it down.

 o drawNextPage()
 o flush()
 o flushLine()
flush()'s, with a newline as well
 o forceTerminal(String)
Terminals can be autodetected, or overridden by 'forcing' them (using, incidently, this routine)
 o getTerminal()
 o hiddenInput(String)
This function is very similar to input(), above, except that it should be used to *not* echo text as it's entered, mainly for passwords
 o input(String)
This function blocks until a line of input is recieved.
 o isPaging()
returns true if we need to output a 'paging' prompt
 o paragraph(String, int, int, int, int, boolean, boolean, boolean)
A not-so-trivial routine that does word-wrap'ing WITH colour codes, and outputs the result through the pager (if required) down the users terminal.
 o quitPager()
 o resetTerminal()
 o send(char, String)
 o send(Paragraph)
 o send(Paragraph, boolean)
 o send(String)
 o sendColumnParagraph(ColumnParagraph, boolean, boolean)
 o sendHeadingParagraph(String, int, boolean, boolean)
 o sendLine()
draw a line across the screen
 o sendRaw(String)
This function sends this raw text to the players screen.
 o sendSubliminal(String, int, int)
You never know what they _might_ have available on their terminal...
 o sendTableParagraph(TableParagraph, boolean, boolean)
 o sendText(String)
Meant to be used to send part of what would normally be a paragraph.
 o sendTextParagraph(int, int, int, int, String, int, boolean, boolean)
 o setCanPage(boolean)
 o setDetectedTerminal(String)
 o spaces(int)
Returns a string of the specified number of spaces

This routine has been optimised for up to 70 spaces, requesting more than this will slow it down.

Variables

 o SMALLEST_BELIEVABLE_WIDTH
 public static final int SMALLEST_BELIEVABLE_WIDTH
 o SMALLEST_BELIEVABLE_HEIGHT
 public static final int SMALLEST_BELIEVABLE_HEIGHT
 o DEFAULT_WIDTH
 public static final int DEFAULT_WIDTH
 o DEFAULT_HEIGHT
 public static final int DEFAULT_HEIGHT
 o PAGER_VERTICAL_SPACE
 public static final int PAGER_VERTICAL_SPACE
The amount of additional space the pager reserves at the bottom of the screen. 3 allows one blank line and a message line, without forcing a scroll.

 o PAGER_THRESHOLD
 public static final int PAGER_THRESHOLD
The number of lines less than the terminal height which is the border between paging and not paging

 o PAGER_LACKS_PAGES
 public static final String PAGER_LACKS_PAGES
 o canPageEver
 public boolean canPageEver
 o CRLF
 public static final String CRLF
 o INPUT_BUFFER
 public static final int INPUT_BUFFER
 o MAX_OVERRUN
 public static final int MAX_OVERRUN

Constructors

 o TelnetConnection
 public TelnetConnection(Socket s)
Constructor

Parameters:
s - The socket that the connection is on

Methods

 o setDetectedTerminal
 public boolean setDetectedTerminal(String name)
 o forceTerminal
 public boolean forceTerminal(String name)
Terminals can be autodetected, or overridden by 'forcing' them (using, incidently, this routine)

 o resetTerminal
 public void resetTerminal()
 o getTerminal
 public Terminal getTerminal()
 o check
 public void check() throws IOException
This function will be called every 'now and again', as a 'check' function when no input is required (we're not waiting), but some is allowed. This is useful for the telnet protocol in particular, which can recieve IAC's before the login prompt. This function should be harmless, no matter when its called

Overrides:
check in class InteractiveConnection
 o input
 public String input(String prompt) throws IOException
This function blocks until a line of input is recieved. Think of it as being much like the input statement in BASIC of old. *shudder*

Parameters:
prompt - The prompt to give the player
Overrides:
input in class InteractiveConnection
 o hiddenInput
 public String hiddenInput(String prompt) throws IOException
This function is very similar to input(), above, except that it should be used to *not* echo text as it's entered, mainly for passwords

Overrides:
hiddenInput in class InteractiveConnection
 o sendRaw
 public void sendRaw(String message)
This function sends this raw text to the players screen. It shouldn't really be used very often - far better to classify data better (from a future expansion pov).

\n is *not* appended to the end of this string

Overrides:
sendRaw in class InteractiveConnection
 o sendLine
 public void sendLine()
draw a line across the screen

Overrides:
sendLine in class InteractiveConnection
 o send
 public void send(String message)
Overrides:
send in class InteractiveConnection
 o sendText
 public void sendText(String message)
Meant to be used to send part of what would normally be a paragraph.

Overrides:
sendText in class InteractiveConnection
 o flush
 protected void flush()
 o flushLine
 protected void flushLine()
flush()'s, with a newline as well

 o send
 public void send(char qualifier,
                  String message)
Overrides:
send in class InteractiveConnection
 o sendTextParagraph
 protected void sendTextParagraph(int li,
                                  int ri,
                                  int lfi,
                                  int rfi,
                                  String message,
                                  int alignment,
                                  boolean appending,
                                  boolean okayToPage)
 o sendColumnParagraph
 protected void sendColumnParagraph(ColumnParagraph tp,
                                    boolean appending,
                                    boolean okayToPage)
 o sendTableParagraph
 protected void sendTableParagraph(TableParagraph tp,
                                   boolean appending,
                                   boolean okayToPage)
 o sendHeadingParagraph
 protected void sendHeadingParagraph(String message,
                                     int alignment,
                                     boolean appending,
                                     boolean okayToPage)
 o send
 public final void send(Paragraph para)
Overrides:
send in class InteractiveConnection
 o send
 public void send(Paragraph para,
                  boolean okayToPage)
Overrides:
send in class InteractiveConnection
 o blankLine
 public void blankLine()
leave some blank space (usually the height of the characters

Overrides:
blankLine in class InteractiveConnection
 o sendSubliminal
 public void sendSubliminal(String message,
                            int duration,
                            int frequency)
You never know what they _might_ have available on their terminal... *grin*

Overrides:
sendSubliminal in class InteractiveConnection
 o paragraph
 public void paragraph(String message,
                       int li,
                       int ri,
                       int lfi,
                       int rfi,
                       boolean stripLeadingSpaces,
                       boolean appending,
                       boolean okayToPage)
A not-so-trivial routine that does word-wrap'ing WITH colour codes, and outputs the result through the pager (if required) down the users terminal.

(Funny... this routine was a lot harder to write in C++)

Anything put in preLine is additional to the left indent - so to guarantee a left indent of 4, ensure you subtract the length of preLine

Setting prelines that are wider than the terminal has an undefined effect on the output.

Parameters:
message - The text to format
li - Leftedge Indent
ri - Rightedge Indent
lfi - Leftedge Firstline Indent (in addition to the leftedge)
rfi - Rightedge Firstline Indent (in addition to the rightedge)
preLine - A string constant to put at the start of every line
 o canPage
 public boolean canPage()
 o setCanPage
 public void setCanPage(boolean b)
 o isPaging
 public boolean isPaging()
returns true if we need to output a 'paging' prompt

Overrides:
isPaging in class InteractiveConnection
 o quitPager
 public void quitPager()
 o drawNextPage
 public void drawNextPage()
 o spaces
 public static String spaces(int n)
Returns a string of the specified number of spaces

This routine has been optimised for up to 70 spaces, requesting more than this will slow it down.

 o dashes
 public static String dashes(int n)
Returns a string of the specified number of dashes

This routine has been optimised for up to 70 spaces, requesting more than this will slow it down.


All Packages  Class Hierarchy  This Package  Previous  Next  Index