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
ConstructorsConstructorDescriptionTelnetTtyConnection(boolean inBinary, boolean outBinary, Charset charset, Consumer<org.aesh.terminal.Connection> handler) Creates a new TelnetTtyConnection. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()org.aesh.terminal.Devicedevice()voidExecutes a task on the per-connection readline executor if the connection is accepted, otherwise falls back to the Netty event loop.longReturns the timestamp of the last access to this connection.voidonClose()The telnet connection closed.voidonData(byte[] data) Process data sent by the client.voidonOpen(TelnetConnection conn) The telnet connection opened.voidonReceiveBinary(boolean binary) Called when the receive binary mode state changes.voidonSendBinary(boolean binary) Called when the send binary mode state changes.voidonSize(int width, int height) Called when the terminal window size changes.voidonTerminalType(String terminalType) Called when the terminal type is received from the client.voidvoidbooleanvoidSchedules a task for delayed execution on the per-connection readline executor.voidsetAttributes(org.aesh.terminal.Attributes attr) org.aesh.terminal.tty.Sizesize()booleanReturns 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, themeChangeHandlerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aesh.terminal.Connection
append, append, append, asPrintWriter, asWriter, close, currentRegion, enterRawMode, isInteractive, peek, printAbove, setCurrentRegion, splitScreen, splitScreen, supportsNonBlockingRead, writeMethods 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 inputoutBinary- true to enable binary mode for outputcharset- the charset to use for encoding/decodinghandler- 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
Returns the terminal type reported by the client.- Returns:
- the terminal type string, or null if not yet received
-
execute
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
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 executedelay- the delay before executionunit- the time unit of the delay
-
inputEncoding
- Specified by:
inputEncodingin interfaceorg.aesh.terminal.Connection
-
outputEncoding
- Specified by:
outputEncodingin interfaceorg.aesh.terminal.Connection
-
supportsAnsi
public boolean supportsAnsi()- Specified by:
supportsAnsiin interfaceorg.aesh.terminal.Connection
-
onSendBinary
public void onSendBinary(boolean binary) Description copied from interface:TelnetHandlerCalled when the send binary mode state changes.- Specified by:
onSendBinaryin interfaceTelnetHandler- Parameters:
binary- true if binary mode is enabled for sending, false otherwise
-
onReceiveBinary
public void onReceiveBinary(boolean binary) Description copied from interface:TelnetHandlerCalled when the receive binary mode state changes.- Specified by:
onReceiveBinaryin interfaceTelnetHandler- Parameters:
binary- true if binary mode is enabled for receiving, false otherwise
-
onData
public void onData(byte[] data) Description copied from interface:TelnetHandlerProcess data sent by the client.- Specified by:
onDatain interfaceTelnetHandler- Parameters:
data- the data
-
onOpen
Description copied from interface:TelnetHandlerThe telnet connection opened.- Specified by:
onOpenin interfaceTelnetHandler- Parameters:
conn- the connection
-
onTerminalType
Description copied from interface:TelnetHandlerCalled when the terminal type is received from the client.- Specified by:
onTerminalTypein interfaceTelnetHandler- Parameters:
terminalType- the terminal type string (e.g., "xterm", "vt100")
-
size
public org.aesh.terminal.tty.Size size()- Specified by:
sizein interfaceorg.aesh.terminal.Connection
-
onSize
public void onSize(int width, int height) Description copied from interface:TelnetHandlerCalled when the terminal window size changes.- Specified by:
onSizein interfaceTelnetHandler- Parameters:
width- the new terminal width in columnsheight- the new terminal height in rows
-
device
public org.aesh.terminal.Device device()- Specified by:
devicein interfaceorg.aesh.terminal.Connection
-
onClose
public void onClose()Description copied from interface:TelnetHandlerThe telnet connection closed.- Specified by:
onClosein interfaceTelnetHandler
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceorg.aesh.terminal.Connection
-
openBlocking
public void openBlocking()- Specified by:
openBlockingin interfaceorg.aesh.terminal.Connection
-
openNonBlocking
public void openNonBlocking()- Specified by:
openNonBlockingin interfaceorg.aesh.terminal.Connection
-
put
- Specified by:
putin interfaceorg.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:
setAttributesin interfaceorg.aesh.terminal.Connection- Overrides:
setAttributesin classorg.aesh.terminal.AbstractConnection
-