Class TelnetTtyConnection

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

public final class TelnetTtyConnection extends TelnetHandler implements Connection
A telnet handler that implements Connection.
Author:
Julien Viet
  • Field Details

  • Constructor Details

    • TelnetTtyConnection

      public TelnetTtyConnection(boolean inBinary, boolean outBinary, Charset charset, Consumer<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 connection's event loop.
      Parameters:
      task - the task to execute
    • schedule

      public void schedule(Runnable task, long delay, TimeUnit unit)
      Schedules a task to be executed after a delay.
      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 Connection
    • outputEncoding

      public Charset outputEncoding()
      Specified by:
      outputEncoding in interface Connection
    • supportsAnsi

      public boolean supportsAnsi()
      Specified by:
      supportsAnsi in interface Connection
    • onSendBinary

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

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

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

      protected void onOpen(TelnetConnection conn)
      Description copied from class: TelnetHandler
      The telnet connection opened.
      Overrides:
      onOpen in class TelnetHandler
      Parameters:
      conn - the connection
    • onTerminalType

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

      public Size size()
      Specified by:
      size in interface Connection
    • onSize

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

      public Device device()
      Specified by:
      device in interface Connection
    • getSizeHandler

      public Consumer<Size> getSizeHandler()
      Specified by:
      getSizeHandler in interface Connection
    • setSizeHandler

      public void setSizeHandler(Consumer<Size> handler)
      Specified by:
      setSizeHandler in interface Connection
    • getSignalHandler

      public Consumer<Signal> getSignalHandler()
      Specified by:
      getSignalHandler in interface Connection
    • setSignalHandler

      public void setSignalHandler(Consumer<Signal> handler)
      Specified by:
      setSignalHandler in interface Connection
    • getStdinHandler

      public Consumer<int[]> getStdinHandler()
      Specified by:
      getStdinHandler in interface Connection
    • setStdinHandler

      public void setStdinHandler(Consumer<int[]> handler)
      Specified by:
      setStdinHandler in interface Connection
    • stdoutHandler

      public Consumer<int[]> stdoutHandler()
      Specified by:
      stdoutHandler in interface Connection
    • setCloseHandler

      public void setCloseHandler(Consumer<Void> closeHandler)
      Specified by:
      setCloseHandler in interface Connection
    • getCloseHandler

      public Consumer<Void> getCloseHandler()
      Specified by:
      getCloseHandler in interface Connection
    • onClose

      protected void onClose()
      Description copied from class: TelnetHandler
      The telnet connection closed.
      Overrides:
      onClose in class TelnetHandler
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Connection
    • openBlocking

      public void openBlocking()
      Specified by:
      openBlocking in interface Connection
    • openNonBlocking

      public void openNonBlocking()
      Specified by:
      openNonBlocking in interface Connection
    • reading

      public boolean reading()
      Specified by:
      reading in interface Connection
    • put

      public boolean put(Capability capability, Object... params)
      Specified by:
      put in interface Connection
    • getAttributes

      public Attributes getAttributes()
      Specified by:
      getAttributes in interface Connection
    • setAttributes

      public void setAttributes(Attributes attr)
      Specified by:
      setAttributes in interface Connection