Class TelnetConnection
java.lang.Object
org.aesh.terminal.telnet.TelnetConnection
- Direct Known Subclasses:
NettyTelnetConnection
Abstract base class for managing Telnet protocol connections and option negotiation.
- Author:
- Julien Viet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteTelnet DO option negotiation byte.static final byteTelnet DON'T option negotiation byte.static final byteTelnet IAC (Interpret As Command) byte.static final byteTelnet SB (subnegotiation begin) byte.static final byteTelnet SE (subnegotiation end) byte.static final byteTelnet WILL option negotiation byte.static final byteTelnet WON'T option negotiation byte. -
Constructor Summary
ConstructorsConstructorDescriptionTelnetConnection(TelnetHandler handler) Creates a new TelnetConnection with the specified handler. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclose()Closes the telnet connection.protected abstract voidprotected voidonClose()voidonInit()Initializes the connection and notifies the handler that it is open.protected voidonOptionDo(byte optionCode) Handle optionDOcall back.protected voidonOptionDont(byte optionCode) Handle optionDON'Tcall back.protected voidonOptionParameters(byte optionCode, byte[] parameters) Handle option parameters call back.protected voidonOptionWill(byte optionCode) Handle optionWILLcall back.protected voidonOptionWont(byte optionCode) Handle optionWON'Tcall back.voidreceive(byte[] data) Receives and processes incoming data from the telnet client.protected abstract voidprotected abstract voidsend(byte[] data) final voidwrite(byte[] data) Write data to the client, escaping data if necessary or truncating it.final voidwriteDoOption(Option option) Write a do option request to the client.final voidwriteWillOption(Option option) Write a do will request to the client.
-
Field Details
-
BYTE_IAC
public static final byte BYTE_IACTelnet IAC (Interpret As Command) byte.- See Also:
-
BYTE_DONT
public static final byte BYTE_DONTTelnet DON'T option negotiation byte.- See Also:
-
BYTE_DO
public static final byte BYTE_DOTelnet DO option negotiation byte.- See Also:
-
BYTE_WONT
public static final byte BYTE_WONTTelnet WON'T option negotiation byte.- See Also:
-
BYTE_WILL
public static final byte BYTE_WILLTelnet WILL option negotiation byte.- See Also:
-
BYTE_SB
public static final byte BYTE_SBTelnet SB (subnegotiation begin) byte.- See Also:
-
BYTE_SE
public static final byte BYTE_SETelnet SE (subnegotiation end) byte.- See Also:
-
-
Constructor Details
-
TelnetConnection
Creates a new TelnetConnection with the specified handler.- Parameters:
handler- the handler for processing telnet events
-
-
Method Details
-
onInit
public void onInit()Initializes the connection and notifies the handler that it is open. -
close
public abstract void close()Closes the telnet connection. -
writeDoOption
Write a do option request to the client.- Parameters:
option- the option to send
-
writeWillOption
Write a do will request to the client.- Parameters:
option- the option to send
-
execute
-
schedule
-
send
protected abstract void send(byte[] data) -
receive
public void receive(byte[] data) Receives and processes incoming data from the telnet client.- Parameters:
data- the raw byte data received
-
write
public final void write(byte[] data) Write data to the client, escaping data if necessary or truncating it. The original buffer can be mutated if incorrect data is provided.- Parameters:
data- the data to write
-
onClose
protected void onClose() -
onOptionWill
protected void onOptionWill(byte optionCode) Handle optionWILLcall back. The implementation will try to find a matching option via theOption#values()and invoke it'sOption.handleWill(TelnetConnection)method otherwise aDON'Twill be sent to the client.This method can be subclassed to handle an option.
- Parameters:
optionCode- the option code
-
onOptionWont
protected void onOptionWont(byte optionCode) Handle optionWON'Tcall back. The implementation will try to find a matching option via theOption#values()and invoke it'sOption.handleWont(TelnetConnection)method.This method can be subclassed to handle an option.
- Parameters:
optionCode- the option code
-
onOptionDo
protected void onOptionDo(byte optionCode) Handle optionDOcall back. The implementation will try to find a matching option via theOption#values()and invoke it'sOption.handleDo(TelnetConnection)method otherwise aWON'Twill be sent to the client.This method can be subclassed to handle an option.
- Parameters:
optionCode- the option code
-
onOptionDont
protected void onOptionDont(byte optionCode) Handle optionDON'Tcall back. The implementation will try to find a matching option via theOption#values()and invoke it'sOption.handleDont(TelnetConnection)method.This method can be subclassed to handle an option.
- Parameters:
optionCode- the option code
-
onOptionParameters
protected void onOptionParameters(byte optionCode, byte[] parameters) Handle option parameters call back. The implementation will try to find a matching option via theOption#values()and invoke it'sOption.handleParameters(TelnetConnection, byte[])method. This method can be subclassed to handle an option.- Parameters:
optionCode- the option code
-