Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindbright.net.telnet
Class TelnetTerminalAdapter

    java.lang.Object
      com.mindbright.terminal.TerminalInputChaff
          com.mindbright.net.telnet.TelnetTerminalAdapter

All Implemented Interfaces:
  java.lang.Runnable, TelnetEventHandler, TerminalInputListener

Direct Known Subclasses:
  ModuleTelnetImpl.ChaffedTelnet

public class TelnetTerminalAdapter
extends TerminalInputChaff
implements TelnetEventHandler

Glue class which connects a `TerminalWindow` to a telnet server.

See Also:
  `TelnetNVT`, `TerminalWindow`, `TerminalInputChaff`

Constructor Summary
`TelnetTerminalAdapter(java.io.InputStream in, java.io.OutputStream out, TerminalWindow terminal)` Connects the given `TerminalWindow` to a telnet server at the other end of the provided streams.

Method Summary
`TelnetNVT` | `getTelnetNVT()` Get the underlying telnet protocol instance.
`void` | `interpretAsCommand(int cmd)` Called to handle some telnet protocol commands from the server.
`boolean` | `isBuffered()` Tells if input is sent directly to server (raw mode) or line by line (cooked).
`boolean` | `optionNegotiation(int option, int request)` Called to handle option negotiation packets from the server.
`void` | `optionSubNegotiation(int option, byte[] params)` Called to handle option negotiation packets from the server.
`void` | `receiveData(byte b)` Handle a byte received from the server.
`void` | `sendBreak()` Send a break to the terminal server.
`void` | `sendBytes(byte[] b)` Send a number of bytes to the server.
`protected void` | `sendFakeChar()` Send a fake character to the server.
`protected void` | `sendTypedChar(int c)` Send a typed char to the server.
`void` | `signalWindowChanged(int rows, int cols, int vpixels, int hpixels)` Tell the telnet server that our window has changed size.

Methods inherited from class com.mindbright.terminal.TerminalInputChaff
`dispenseChaff, isChaffActive, run, signalTermTypeChanged, startChaff, stopChaff, typedChar, typedChar`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TelnetTerminalAdapter

    public TelnetTerminalAdapter(java.io.InputStream in,
                                 java.io.OutputStream out,
                                 TerminalWindow terminal)

  Connects the given `TerminalWindow` to a telnet server at the other end of the provided streams.

Parameters:
  `in` - stream from which data from the telnet server is read
  `out` - stream over which to send data to the telnet server
  `terminal` - instance of terminal window to connect to

Method Detail

### getTelnetNVT

    public TelnetNVT getTelnetNVT()

  Get the underlying telnet protocol instance.

### isBuffered

    public boolean isBuffered()

  Tells if input is sent directly to server (raw mode) or line by line (cooked).

  Returns:
    true if input is sent line-by-line

### interpretAsCommand

    public void interpretAsCommand(int cmd)

  Description copied from interface: `TelnetEventHandler`
  Called to handle some telnet protocol commands from the server.

  Specified by:
    `interpretAsCommand` in interface `TelnetEventHandler`

### optionSubNegotiation

    public void optionSubNegotiation(int option,
                                     byte[] params)
                              throws java.io.IOException

  Description copied from interface: `TelnetEventHandler`
  Called to handle option negotiation packets from the server. The implementation is expected to modify its internal state accordingly and reply by invoking the relevant function (like `sendOptionSubNegotiation`

  Specified by:
    `optionSubNegotiation` in interface `TelnetEventHandler`
  Throws:
    `java.io.IOException`

### optionNegotiation

    public boolean optionNegotiation(int option,
                                     int request)
                              throws java.io.IOException

  Description copied from interface: `TelnetEventHandler`
  Called to handle option negotiation packets from the server. The implementation is expected to modify its internal state accordingly and reply by invoking the relevant function (like `doOption` and `willOption`

  Specified by:
    `optionNegotiation` in interface `TelnetEventHandler`
  Throws:
    `java.io.IOException`

### receiveData

    public void receiveData(byte b)

  Description copied from interface: `TelnetEventHandler`
  Handle a byte received from the server.

  Specified by:
    `receiveData` in interface `TelnetEventHandler`

### sendTypedChar

    protected void sendTypedChar(int c)

  Send a typed char to the server. The character may not be sent directly if the terminal is in buffered mode.

  Specified by:
    `sendTypedChar` in class `TerminalInputChaff`
  Parameters:
    `c` - typed character

### sendFakeChar

    protected void sendFakeChar()

  Description copied from class: `TerminalInputChaff`
  Send a fake character to the server.

  Specified by:
    `sendFakeChar` in class `TerminalInputChaff`

### sendBytes

    public void sendBytes(byte[] b)

  Send a number of bytes to the server.

  Specified by:
    `sendBytes` in interface `TerminalInputListener`
  Parameters:
    `b` - array of bytes representing characters to input

### signalWindowChanged

    public void signalWindowChanged(int rows,
                                    int cols,
                                    int vpixels,
                                    int hpixels)

  Tell the telnet server that our window has changed size.

  Specified by:
    `signalWindowChanged` in interface `TerminalInputListener`
  Parameters:
    `rows` - new number of rows
    `cols` - new number of columns
    `vpixels` - number of verticial pixels
    `hpixels` - number of horizontal pixels

### sendBreak

    public void sendBreak()

  Send a break to the terminal server.

  Specified by:
    `sendBreak` in interface `TerminalInputListener`
  Overrides:
    `sendBreak` in class `TerminalInputChaff`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD