org.opengts.util
Interface ClientPacketHandler

All Known Implementing Classes:
AbstractClientPacketHandler, CommandHandler, CommandHandler, CommandPacketHandler, TemplateCommandHandler, 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
 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
 int getResponsePort()
          Return the port for UDP Datagram responses
 ServerSocketThread.SessionInfo getSessionInfo()
          Gets a reference to the ClientPacketHandler's session info implementation
 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 setSessionInfo(ServerSocketThread.SessionInfo sessionInfo)
          Sets the session info handler
 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()
          Indicates if the session should terminate
 

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

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

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

terminateSession

boolean terminateSession()
Indicates if the session should terminate

Returns:
True if the session should terminate

sessionTerminated

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

Parameters:
err -
readCount -
writeCount -