Class TelnetTtyConnection
java.lang.Object
org.aesh.terminal.telnet.TelnetHandler
org.aesh.terminal.telnet.TelnetTtyConnection
- All Implemented Interfaces:
AutoCloseable, Connection
A telnet handler that implements
Connection.- Author:
- Julien Viet
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTelnetTtyConnection(boolean inBinary, boolean outBinary, Charset charset, Consumer<Connection> handler) Creates a new TelnetTtyConnection. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()device()voidExecutes a task on the connection's event loop.Consumer<int[]> longReturns the timestamp of the last access to this connection.protected voidonClose()The telnet connection closed.protected voidonData(byte[] data) Process data sent by the client.protected voidonOpen(TelnetConnection conn) The telnet connection opened.protected voidonReceiveBinary(boolean binary) Called when the receive binary mode state changes.protected voidonSendBinary(boolean binary) Called when the send binary mode state changes.protected voidonSize(int width, int height) Called when the terminal window size changes.protected voidonTerminalType(String terminalType) Called when the terminal type is received from the client.voidvoidbooleanput(Capability capability, Object... params) booleanreading()voidSchedules a task to be executed after a delay.voidsetAttributes(Attributes attr) voidsetCloseHandler(Consumer<Void> closeHandler) voidsetSignalHandler(Consumer<Signal> handler) voidsetSizeHandler(Consumer<Size> handler) voidsetStdinHandler(Consumer<int[]> handler) size()Consumer<int[]> booleanReturns the terminal type reported by the client.Methods inherited from class TelnetHandler
onCommand, onEcho, onNAWS, onSGAMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Connection
close, enterRawMode, getColorCapability, getColorDepth, getCursorPosition, getTerminalType, queryAnsi16Colors, queryBackgroundColor, queryBatchOsc, queryColorCapability, queryColors, queryCursorColor, queryDeviceAttributes, queryForegroundColor, queryImageProtocol, queryOsc, queryOsc, queryPaletteColor, queryPaletteColorIfSupported, queryPaletteColors, queryPrimaryDeviceAttributes, querySecondaryDeviceAttributes, querySupportsOscQueries, queryTerminal, queryWithResponseBuffering, supportsClipboard, supportsColorQuery, supportsOscCode, supportsOscQueries, supportsOscQueries, supportsPaletteQuery, write
-
Field Details
-
conn
The underlying telnet connection.
-
-
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 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 connection's event loop.- Parameters:
task- the task to execute
-
schedule
-
inputEncoding
- Specified by:
inputEncodingin interfaceConnection
-
outputEncoding
- Specified by:
outputEncodingin interfaceConnection
-
supportsAnsi
public boolean supportsAnsi()- Specified by:
supportsAnsiin interfaceConnection
-
onSendBinary
protected void onSendBinary(boolean binary) Description copied from class:TelnetHandlerCalled when the send binary mode state changes.- Overrides:
onSendBinaryin classTelnetHandler- Parameters:
binary- true if binary mode is enabled for sending, false otherwise
-
onReceiveBinary
protected void onReceiveBinary(boolean binary) Description copied from class:TelnetHandlerCalled when the receive binary mode state changes.- Overrides:
onReceiveBinaryin classTelnetHandler- Parameters:
binary- true if binary mode is enabled for receiving, false otherwise
-
onData
protected void onData(byte[] data) Description copied from class:TelnetHandlerProcess data sent by the client.- Overrides:
onDatain classTelnetHandler- Parameters:
data- the data
-
onOpen
Description copied from class:TelnetHandlerThe telnet connection opened.- Overrides:
onOpenin classTelnetHandler- Parameters:
conn- the connection
-
onTerminalType
Description copied from class:TelnetHandlerCalled when the terminal type is received from the client.- Overrides:
onTerminalTypein classTelnetHandler- Parameters:
terminalType- the terminal type string (e.g., "xterm", "vt100")
-
size
- Specified by:
sizein interfaceConnection
-
onSize
protected void onSize(int width, int height) Description copied from class:TelnetHandlerCalled when the terminal window size changes.- Overrides:
onSizein classTelnetHandler- Parameters:
width- the new terminal width in columnsheight- the new terminal height in rows
-
device
- Specified by:
devicein interfaceConnection
-
getSizeHandler
- Specified by:
getSizeHandlerin interfaceConnection
-
setSizeHandler
- Specified by:
setSizeHandlerin interfaceConnection
-
getSignalHandler
- Specified by:
getSignalHandlerin interfaceConnection
-
setSignalHandler
- Specified by:
setSignalHandlerin interfaceConnection
-
getStdinHandler
- Specified by:
getStdinHandlerin interfaceConnection
-
setStdinHandler
- Specified by:
setStdinHandlerin interfaceConnection
-
stdoutHandler
- Specified by:
stdoutHandlerin interfaceConnection
-
setCloseHandler
- Specified by:
setCloseHandlerin interfaceConnection
-
getCloseHandler
- Specified by:
getCloseHandlerin interfaceConnection
-
onClose
protected void onClose()Description copied from class:TelnetHandlerThe telnet connection closed.- Overrides:
onClosein classTelnetHandler
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection
-
openBlocking
public void openBlocking()- Specified by:
openBlockingin interfaceConnection
-
openNonBlocking
public void openNonBlocking()- Specified by:
openNonBlockingin interfaceConnection
-
reading
public boolean reading()- Specified by:
readingin interfaceConnection
-
put
- Specified by:
putin interfaceConnection
-
getAttributes
- Specified by:
getAttributesin interfaceConnection
-
setAttributes
- Specified by:
setAttributesin interfaceConnection
-