Class TelnetTtyConnection

java.lang.Object
org.aesh.terminal.AbstractConnection
org.aesh.terminal.telnet.TelnetTtyConnection
All Implemented Interfaces:
Appendable, AutoCloseable, org.aesh.terminal.Connection, TelnetHandler

public final class TelnetTtyConnection extends org.aesh.terminal.AbstractConnection implements TelnetHandler
A telnet handler that implements Connection via AbstractConnection.

Extends AbstractConnection for common handler plumbing (signal, stdin, stdout, size, close, mouse, focus, theme change, printAbove, statusLine) and implements TelnetHandler for telnet protocol callbacks.

Author:
Julien Viet
  • Field Summary

    Fields inherited from class org.aesh.terminal.AbstractConnection

    attributes, closeHandler, eventDecoder, reading, sizeHandler, stdout
  • Constructor Summary

    Constructors
    Constructor
    Description
    TelnetTtyConnection(boolean inBinary, boolean outBinary, Charset charset, Consumer<org.aesh.terminal.Connection> handler)
    Creates a new TelnetTtyConnection.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    org.aesh.terminal.Device
     
    void
    Executes a task on the per-connection readline executor if the connection is accepted, otherwise falls back to the Netty event loop.
     
    long
    Returns the timestamp of the last access to this connection.
    void
    The telnet connection closed.
    void
    onData(byte[] data)
    Process data sent by the client.
    void
    The telnet connection opened.
    void
    onReceiveBinary(boolean binary)
    Called when the receive binary mode state changes.
    void
    onSendBinary(boolean binary)
    Called when the send binary mode state changes.
    void
    onSize(int width, int height)
    Called when the terminal window size changes.
    void
    onTerminalType(String terminalType)
    Called when the terminal type is received from the client.
    void
     
    void
     
     
    boolean
    put(org.aesh.terminal.tty.Capability capability, Object... params)
     
    void
    schedule(Runnable task, long delay, TimeUnit unit)
    Schedules a task for delayed execution on the per-connection readline executor.
    void
    setAttributes(org.aesh.terminal.Attributes attr)
    org.aesh.terminal.tty.Size
     
    boolean
     
    Returns the terminal type reported by the client.

    Methods inherited from class org.aesh.terminal.AbstractConnection

    attributes, closeHandler, focusHandler, getStatusMessages, mouseHandler, printAboveHandler, reading, registerStatusLine, setCloseHandler, setFocusHandler, setMouseHandler, setPrintAboveHandler, setSignalHandler, setSizeHandler, setStdinHandler, setThemeChangeHandler, signalHandler, sizeHandler, stdinHandler, stdoutHandler, terminal, themeChangeHandler

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.aesh.terminal.Connection

    append, append, append, asPrintWriter, asWriter, close, currentRegion, enterRawMode, isInteractive, peek, printAbove, setCurrentRegion, splitScreen, splitScreen, supportsNonBlockingRead, write

    Methods inherited from interface TelnetHandler

    onCommand, onEcho, onNAWS, onSGA
  • Constructor Details

    • TelnetTtyConnection

      public TelnetTtyConnection(boolean inBinary, boolean outBinary, Charset charset, Consumer<org.aesh.terminal.Connection> handler)
      Creates a new TelnetTtyConnection.
      Parameters:
      inBinary - true to enable binary mode for input
      outBinary - true to enable binary mode for output
      charset - the charset to use for encoding/decoding
      handler - the connection handler to be notified when the connection is established
  • Method Details

    • lastAccessedTime

      public long lastAccessedTime()
      Returns the timestamp of the last access to this connection.
      Returns:
      the last accessed time in milliseconds since epoch
    • terminalType

      public String terminalType()
      Returns the terminal type reported by the client.
      Returns:
      the terminal type string, or null if not yet received
    • execute

      public void execute(Runnable task)
      Executes a task on the per-connection readline executor if the connection is accepted, otherwise falls back to the Netty event loop.

      Before acceptance, tasks (like ReadBuffer.drainQueue) must run on the Netty event loop to stay synchronized with option negotiation. After acceptance, tasks are offloaded to the readline executor.

      Parameters:
      task - the task to execute
    • schedule

      public void schedule(Runnable task, long delay, TimeUnit unit)
      Schedules a task for delayed execution on the per-connection readline executor. Falls back to the Netty event loop if the executor is not yet initialized, the connection is not yet accepted, or the executor has been shut down.
      Parameters:
      task - the task to execute
      delay - the delay before execution
      unit - the time unit of the delay
    • inputEncoding

      public Charset inputEncoding()
      Specified by:
      inputEncoding in interface org.aesh.terminal.Connection
    • outputEncoding

      public Charset outputEncoding()
      Specified by:
      outputEncoding in interface org.aesh.terminal.Connection
    • supportsAnsi

      public boolean supportsAnsi()
      Specified by:
      supportsAnsi in interface org.aesh.terminal.Connection
    • onSendBinary

      public void onSendBinary(boolean binary)
      Description copied from interface: TelnetHandler
      Called when the send binary mode state changes.
      Specified by:
      onSendBinary in interface TelnetHandler
      Parameters:
      binary - true if binary mode is enabled for sending, false otherwise
    • onReceiveBinary

      public void onReceiveBinary(boolean binary)
      Description copied from interface: TelnetHandler
      Called when the receive binary mode state changes.
      Specified by:
      onReceiveBinary in interface TelnetHandler
      Parameters:
      binary - true if binary mode is enabled for receiving, false otherwise
    • onData

      public void onData(byte[] data)
      Description copied from interface: TelnetHandler
      Process data sent by the client.
      Specified by:
      onData in interface TelnetHandler
      Parameters:
      data - the data
    • onOpen

      public void onOpen(TelnetConnection conn)
      Description copied from interface: TelnetHandler
      The telnet connection opened.
      Specified by:
      onOpen in interface TelnetHandler
      Parameters:
      conn - the connection
    • onTerminalType

      public void onTerminalType(String terminalType)
      Description copied from interface: TelnetHandler
      Called when the terminal type is received from the client.
      Specified by:
      onTerminalType in interface TelnetHandler
      Parameters:
      terminalType - the terminal type string (e.g., "xterm", "vt100")
    • size

      public org.aesh.terminal.tty.Size size()
      Specified by:
      size in interface org.aesh.terminal.Connection
    • onSize

      public void onSize(int width, int height)
      Description copied from interface: TelnetHandler
      Called when the terminal window size changes.
      Specified by:
      onSize in interface TelnetHandler
      Parameters:
      width - the new terminal width in columns
      height - the new terminal height in rows
    • device

      public org.aesh.terminal.Device device()
      Specified by:
      device in interface org.aesh.terminal.Connection
    • onClose

      public void onClose()
      Description copied from interface: TelnetHandler
      The telnet connection closed.
      Specified by:
      onClose in interface TelnetHandler
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface org.aesh.terminal.Connection
    • openBlocking

      public void openBlocking()
      Specified by:
      openBlocking in interface org.aesh.terminal.Connection
    • openNonBlocking

      public void openNonBlocking()
      Specified by:
      openNonBlocking in interface org.aesh.terminal.Connection
    • put

      public boolean put(org.aesh.terminal.tty.Capability capability, Object... params)
      Specified by:
      put in interface org.aesh.terminal.Connection
    • setAttributes

      public void setAttributes(org.aesh.terminal.Attributes attr)

      Telnet PTY modes are negotiated during session setup and cannot be changed afterward — this method is intentionally a no-op.

      Specified by:
      setAttributes in interface org.aesh.terminal.Connection
      Overrides:
      setAttributes in class org.aesh.terminal.AbstractConnection