org.opengts.util
Interface ClientPacketHandler

All Known Implementing Classes:
AbstractClientPacketHandler, CommandHandler, CommandHandler, CommandPacketHandler, RemoteLogServer.RemoteLogHandler, TemplateCommandHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler, TrackClientPacketHandler

public interface ClientPacketHandler

Inteface for packet handling clients [CHECK]


Method Summary
 boolean equalsSessionID(java.lang.String sessionID)
          Returns true if the specified session ID matches the current session ID
 void forceCloseTCPSession()
          forces the client TCP session to close
 int getActualPacketLength(byte[] packet, int packetLen)
          Return actual packet length based on this partial packet
 byte[] getFinalPacket(boolean hasError)
          Return final response to the session before it closes
 byte[] getHandlePacket(byte[] cmd)
          Process packet and return response
 byte[] getInitialPacket()
          Return initial response to the open session
 int getMaximumPacketLength()
          Gets the maximum packet length
 int getMinimumPacketLength()
          Gets the minimum packet length
 boolean getPromptEnabled()
          Gets the prompt enabled state
 int getResponsePort()
          Return the port for UDP Datagram responses
 ServerSocketThread.SessionInfo getSessionInfo()
          Gets a reference to the ClientPacketHandler's session info implementation
 boolean getTerminateSession()
          Indicates if the session should terminate
 void idleTimeoutInterrupt()
          Callback: timeout interrupt Called periodically during an idle read.
 void sessionStarted(java.net.InetAddress inetAddr, boolean isTCP, boolean isText)
          Called when new client session initiated
 void sessionTerminated(java.lang.Throwable err, long readCount, long writeCount)
          Called after client session terminated
 void setPromptEnabled(boolean enable)
          Sets the prompt enabled state
 void setSessionInfo(ServerSocketThread.SessionInfo sessionInfo)
          Sets the session info handler
 void setTerminateSession()
          Sets the session termination state (a hint to the session thread that the session should be terminated)
 boolean tcpWrite(byte[] data)
          Write bytes to TCP output stream asynchronously
Instended to be called from a separate thread wishing to write a command asynchronously to the active device session.
 boolean terminateSession()
           
 

Method Detail

sessionStarted

void sessionStarted(java.net.InetAddress inetAddr,
                    boolean isTCP,
                    boolean isText)
Called when new client session initiated

Parameters:
inetAddr - The host IP address
isTCP - True if the connection is TCP
isText - True if the connection is text

sessionTerminated

void sessionTerminated(java.lang.Throwable err,
                       long readCount,
                       long writeCount)
Called after client session terminated

Parameters:
err -
readCount -
writeCount -

equalsSessionID

boolean equalsSessionID(java.lang.String sessionID)
Returns true if the specified session ID matches the current session ID

Parameters:
sessionID - The session ID to test (specifying null should always return false)
Returns:
True if the session IDs match, false otherwise

setSessionInfo

void setSessionInfo(ServerSocketThread.SessionInfo sessionInfo)
Sets the session info handler

Parameters:
sessionInfo - An implementation of the ServerSocketThread.SessionInfo interface

getSessionInfo

ServerSocketThread.SessionInfo getSessionInfo()
Gets a reference to the ClientPacketHandler's session info implementation

Returns:
Reference to the session info object

getInitialPacket

byte[] getInitialPacket()
                        throws java.lang.Exception
Return initial response to the open session

Returns:
The initial response to be sent when the session opens
Throws:
java.lang.Exception

getFinalPacket

byte[] getFinalPacket(boolean hasError)
                      throws java.lang.Exception
Return final response to the session before it closes

Returns:
the final response to be sent before the session closes
Throws:
java.lang.Exception

getMinimumPacketLength

int getMinimumPacketLength()
Gets the minimum packet length

Returns:
The minimum packet length

getMaximumPacketLength

int getMaximumPacketLength()
Gets the maximum packet length

Returns:
The maximum packet length

setPromptEnabled

void setPromptEnabled(boolean enable)
Sets the prompt enabled state

Parameters:
enable - True to enable prompt, false to disable

getPromptEnabled

boolean getPromptEnabled()
Gets the prompt enabled state

Returns:
True to enable prompt, false to disable

idleTimeoutInterrupt

void idleTimeoutInterrupt()
Callback: timeout interrupt Called periodically during an idle read. The periodic timeout is based on the value specified on the call to "ServerSocketThread.setMinimuTimeoutIntervalMS"


getActualPacketLength

int getActualPacketLength(byte[] packet,
                          int packetLen)
Return actual packet length based on this partial packet


getHandlePacket

byte[] getHandlePacket(byte[] cmd)
                       throws java.lang.Exception
Process packet and return response

Parameters:
cmd - The packet
Returns:
The response
Throws:
java.lang.Exception

tcpWrite

boolean tcpWrite(byte[] data)
Write bytes to TCP output stream asynchronously
Instended to be called from a separate thread wishing to write a command asynchronously to the active device session.

Parameters:
data - The data bytes to write
Returns:
True if bytes were written, false otherwise

getResponsePort

int getResponsePort()
Return the port for UDP Datagram responses

Returns:
The port for UDP Datafram responses

forceCloseTCPSession

void forceCloseTCPSession()
forces the client TCP session to close


setTerminateSession

void setTerminateSession()
Sets the session termination state (a hint to the session thread that the session should be terminated)


getTerminateSession

boolean getTerminateSession()
Indicates if the session should terminate

Returns:
True if the session should terminate

terminateSession

boolean terminateSession()