de.mud.telnet
Class TelnetProtocolHandler
java.lang.Object
de.mud.telnet.TelnetProtocolHandler
public abstract class TelnetProtocolHandler
extends java.lang.Object
This is a telnet protocol handler. The handler needs implementations
for several methods to handle the telnet options and to be able to
read and write the buffer.
Maintainer: Marcus Meissner
$Id: TelnetProtocolHandler.java 503 2005-10-24 07:34:13Z marcus $- Matthias L. Jugel, Marcus Meissner
static String | ID - contains the current revision id
|
protected abstract String | getTerminalType() - Get the current terminal type for TTYPE telnet option.
|
protected abstract Dimension | getWindowSize() - Get the current window size of the terminal for the
NAWS telnet option.
|
void | inputfeed(byte[] b, int len)
|
int | negotiate(nbuf[] ) - Handle telnet protocol negotiation.
|
protected abstract void | notifyEndOfRecord() - Generate an EOR (end of record) request.
|
void | reset() - Reset the protocol handler.
|
void | sendTelnetControl(byte code) - Send a Telnet Escape character (IAC
)
|
void | setCR(String xcr)
|
void | setCRLF(String xcrlf)
|
protected abstract void | setLocalEcho(boolean echo) - Set the local echo option of telnet.
|
void | setWindowSize(int columns, int rows) - Send the new Window Size (via NAWS)
|
void | startup() - Do not send any notifications at startup.
|
void | transpose(byte[] buf) - Transpose special telnet codes like 0xff or newlines to values
that are compliant to the protocol.
|
protected abstract void | write(byte[] b) - Send data to the remote host.
|
ID
public static final String ID
contains the current revision id
TelnetProtocolHandler
public TelnetProtocolHandler()
Create a new telnet protocol handler.
getTerminalType
protected abstract String getTerminalType()
Get the current terminal type for TTYPE telnet option.
- the string id of the terminal
getWindowSize
protected abstract Dimension getWindowSize()
Get the current window size of the terminal for the
NAWS telnet option.
- the size of the terminal as Dimension
inputfeed
public void inputfeed(byte[] b,
int len)
negotiate
public int negotiate(nbuf[] )
throws IOException
Handle telnet protocol negotiation. The buffer will be parsed
and necessary actions are taken according to the telnet protocol.
See
RFC-Telnet
- number of bytes processed, 0 for none, and -1 for end of buffer.
notifyEndOfRecord
protected abstract void notifyEndOfRecord()
Generate an EOR (end of record) request. For use by prompt displaying.
reset
public void reset()
Reset the protocol handler. This may be necessary after the
connection was closed or some other problem occured.
sendTelnetControl
public void sendTelnetControl(byte code)
throws IOException
Send a Telnet Escape character (IAC )
setCR
public void setCR(String xcr)
setCRLF
public void setCRLF(String xcrlf)
setLocalEcho
protected abstract void setLocalEcho(boolean echo)
Set the local echo option of telnet.
echo
- true for local echo, false for no local echo
setWindowSize
public void setWindowSize(int columns,
int rows)
throws IOException
Send the new Window Size (via NAWS)
startup
public void startup()
throws IOException
Do not send any notifications at startup. We do not know,
whether the remote client understands telnet protocol handling,
so we are silent.
(This used to send IAC WILL SGA, but this is false for a compliant
client.)
transpose
public void transpose(byte[] buf)
throws IOException
Transpose special telnet codes like 0xff or newlines to values
that are compliant to the protocol. This method will also send
the buffer immediately after transposing the data.
buf
- the data buffer to be sent
write
protected abstract void write(byte[] b)
throws IOException
Send data to the remote host.
b
- array of bytes to send