com.maverick.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.

Author:
Lee David Painter

Field Summary
static int BY_APPLICATION
          Disconnect reason: The application disconnected
 
Method Summary
 void disconnect(int reason, java.lang.String description)
          Disconnect the Engine
 SocketConnection getSocketConnection()
          Get the SocketConnection for this connection.
 boolean isConnected()
          Is the protocol connected.
 void onSocketClose()
          The socket has closed.
 void onSocketConnect(SocketConnection connection)
          The socket is connected and the protocol can now start.
 boolean onSocketRead(java.nio.ByteBuffer applicationData)
          Data has arrived on the socket.
 SocketWriteCallback onSocketWrite(java.nio.ByteBuffer applicationData)
          The socket is ready for writing.
 boolean wantsToWrite()
          Determines whether the protocol wants to write to the socket.
 

Field Detail

BY_APPLICATION

public static final int BY_APPLICATION
Disconnect reason: The application disconnected

See Also:
Constant Field Values
Method Detail

onSocketConnect

public void onSocketConnect(SocketConnection connection)
The socket is connected and the protocol can now start.

Parameters:
connection - SocketConnection

onSocketClose

public void onSocketClose()
The socket has closed.


onSocketRead

public boolean onSocketRead(java.nio.ByteBuffer applicationData)
Data has arrived on the socket.

Parameters:
applicationData - ByteBuffer
Returns:
boolean to determine if protocol wants to write to the socket

onSocketWrite

public SocketWriteCallback onSocketWrite(java.nio.ByteBuffer applicationData)
The socket is ready for writing.

Parameters:
applicationData - ByteBuffer

wantsToWrite

public 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

public boolean isConnected()
Is the protocol connected.

Returns:
boolean

getSocketConnection

public SocketConnection getSocketConnection()
Get the SocketConnection for this connection.

Returns:
SocketConnection

disconnect

public void disconnect(int reason,
                       java.lang.String description)
Disconnect the Engine

Parameters:
reason -
description -


Copyright © 2003-2008 SSHTools LTD. All Rights Reserved.