de.mud.telnet
Class TelnetProtocolHandler

java.lang.Object
  |
  +--de.mud.telnet.TelnetProtocolHandler
Direct Known Subclasses:
TelnetWrapper

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 Meißner

Version:
$Id: TelnetProtocolHandler.java,v 2.14 2001/10/07 20:17:43 marcus Exp $
Author:
Matthias L. Jugel, Marcus Meißner

Field Summary
static java.lang.String ID
          contains the current revision id
 
Constructor Summary
TelnetProtocolHandler()
          Create a new telnet protocol handler.
 
Method Summary
protected abstract  java.lang.String getTerminalType()
          Get the current terminal type for TTYPE telnet option.
protected abstract  java.awt.Dimension getWindowSize()
          Get the current window size of the terminal for the NAWS telnet option.
 void inputfeed(byte[] b, int len)
           
 int negotiate(byte[] 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(java.lang.String xcr)
           
 void setCRLF(java.lang.String xcrlf)
           
protected abstract  void setLocalEcho(boolean echo)
          Set the local echo option of telnet.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final java.lang.String ID
contains the current revision id
Constructor Detail

TelnetProtocolHandler

public TelnetProtocolHandler()
Create a new telnet protocol handler.
Method Detail

getTerminalType

protected abstract java.lang.String getTerminalType()
Get the current terminal type for TTYPE telnet option.
Returns:
the string id of the terminal

getWindowSize

protected abstract java.awt.Dimension getWindowSize()
Get the current window size of the terminal for the NAWS telnet option.
Returns:
the size of the terminal as Dimension

setLocalEcho

protected abstract void setLocalEcho(boolean echo)
Set the local echo option of telnet.
Parameters:
echo - true for local echo, false for no local echo

notifyEndOfRecord

protected abstract void notifyEndOfRecord()
Generate an EOR (end of record) request. For use by prompt displaying.

write

protected abstract void write(byte[] b)
                       throws java.io.IOException
Send data to the remote host.
Parameters:
b - array of bytes to send

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 java.io.IOException
Send a Telnet Escape character (IAC )

startup

public void startup()
             throws java.io.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 java.io.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.
Parameters:
buf - the data buffer to be sent

setCRLF

public void setCRLF(java.lang.String xcrlf)

setCR

public void setCR(java.lang.String xcr)

negotiate

public int negotiate(byte[] nbuf)
              throws java.io.IOException
Handle telnet protocol negotiation. The buffer will be parsed and necessary actions are taken according to the telnet protocol. See RFC-Telnet
Parameters:
buf - the byte buffer used for negotiation
count - the amount of bytes in the buffer
Returns:
a new buffer after negotiation

inputfeed

public void inputfeed(byte[] b,
                      int len)