Package com.sshtools.synergy.nio
Interface ProtocolEngine
- All Known Implementing Classes:
TransportProtocol
public interface ProtocolEngine
This interface defines the contract for a protocol implementation. An
instance of this interface is created for each socket connection.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDisconnect reason: The application disconnected -
Method Summary
Modifier and TypeMethodDescriptionvoiddisconnect(int reason, String description) Disconnect the EngineConnection<? extends SshContext>getName()Get theSocketConnectionfor this connection.booleanIs the protocol connected.voidThe socket has closed.voidonSocketConnect(SocketConnection connection) The socket is connected and the protocol can now start.booleanonSocketRead(ByteBuffer applicationData) Data has arrived on the socket.onSocketWrite(ByteBuffer applicationData) The socket is ready for writing.booleanDetermines whether the protocol wants to write to the socket.
-
Field Details
-
BY_APPLICATION
static final int BY_APPLICATIONDisconnect reason: The application disconnected- See Also:
-
-
Method Details
-
onSocketConnect
The socket is connected and the protocol can now start.- Parameters:
connection- SocketConnection
-
onSocketClose
void onSocketClose()The socket has closed. -
onSocketRead
Data has arrived on the socket.- Parameters:
applicationData- ByteBuffer- Returns:
- boolean to determine if protocol wants to write to the socket
-
onSocketWrite
The socket is ready for writing.- Parameters:
applicationData- ByteBuffer
-
wantsToWrite
boolean wantsToWrite()Determines whether the protocol wants to write to the socket. The value of this method determines the write state of the socket. Only return a true value when the protocol needs to write data to the socket.- Returns:
- boolean
-
isConnected
boolean isConnected()Is the protocol connected.- Returns:
- boolean
-
getSocketConnection
SocketConnection getSocketConnection()Get theSocketConnectionfor this connection.- Returns:
- SocketConnection
-
disconnect
Disconnect the Engine- Parameters:
reason-description-
-
getConnectFuture
ConnectRequestFuture getConnectFuture() -
getDisconnectFuture
DisconnectRequestFuture getDisconnectFuture() -
getExecutor
ExecutorOperationSupport<?> getExecutor() -
getName
String getName() -
getContext
SshContext getContext() -
getConnection
Connection<? extends SshContext> getConnection()
-