|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opengts.util.AbstractClientPacketHandler
public abstract class AbstractClientPacketHandler
An abstract implementation of the ClientPacketHandler
interface
Field Summary | |
---|---|
static java.util.TimeZone |
GMT_Timezone
|
static int |
PACKET_LEN_END_OF_STREAM
|
static int |
PACKET_LEN_LINE_TERMINATOR
|
Constructor Summary | |
---|---|
AbstractClientPacketHandler(java.lang.String name)
|
Method Summary | |
---|---|
void |
clearSavedEventCount()
Clears the event count state |
void |
clearTerminateSession()
Clears the terminate-session state to false |
boolean |
equals(java.lang.Object other)
|
boolean |
equalsSessionID(java.lang.String sessionID)
Returns true if the specified session ID matches the current session ID |
void |
forceCloseTCPSession()
Sets the terminate-session state to the specified value |
int |
getActualPacketLength(byte[] packet,
int packetLen)
Callback to obtain the length of the next packet, based on the provided partial packet data. |
static boolean |
GetDebugMode()
Gets the global debug mode |
byte[] |
getFinalPacket(boolean hasError)
Returns the final packet that should be sent to the device before closing the socket connection. |
abstract byte[] |
getHandlePacket(byte[] cmd)
Parse the provided packet information, and return any response that should be sent back to the remote device |
java.lang.String |
getHostAddress()
Gets the IP adress of the remote host |
java.net.InetAddress |
getInetAddress()
Gets the IP adress of the remote host |
byte[] |
getInitialPacket()
Returns the initial packet that should be sent to the device upon openning the socket connection . |
java.lang.String |
getIPAddress()
Gets the IP adress of the remote host |
int |
getLocalPort()
Gets the local port to which this socket is bound |
int |
getMaximumPacketLength()
Returns the maximum packet length |
int |
getMinimumPacketLength()
Returns the minimum packet length |
java.lang.String |
getName()
|
boolean |
getPromptEnabled()
Gets the prompt enabled state |
int |
getRemotePort()
Gets the remote/client port used by the client to send the received packet |
int |
getResponsePort()
Returns the client response port# |
int |
getSavedEventCount()
Gets the current value of the event count state |
long |
getSequenceID()
|
protected java.lang.String |
getSessionID()
Returns the session ID (override only) |
ServerSocketThread.SessionInfo |
getSessionInfo()
Gets a reference to the ClientPacketHandler's session info implementation |
long |
getSessionStartTime()
Returns the session start time (seconds) |
long |
getSessionStartTimeMS()
Returns the session start time (milliseconds) |
java.lang.String |
getSessionType()
Gets the current session type name (ie. |
boolean |
getTerminateSession()
Callback to determine if the current session should be terminated |
java.lang.String |
getThreadName()
Returns name of the thread handling this client session |
boolean |
hasHostAddress()
Returns true if a remote host address is available |
boolean |
hasIPAddress()
Returns true if a remote host address is available |
boolean |
hasSavedEvents()
Returns true if the current value of the event count state is greater-than zero |
void |
idleTimeoutInterrupt()
Callback: timeout interrupt Called periodically during an idle read. |
void |
incrementSavedEventCount()
Increments the event count state |
static boolean |
IsDebugMode()
Gets the global debug mode |
boolean |
isDuplex()
Returns true if this session is duplex (ie TCP) |
boolean |
isInputStream()
Returns true if this session is InputStream |
boolean |
isTCP()
Returns true if this session is TCP |
protected boolean |
isTextPackets()
Returns true if the packets are text |
boolean |
isUDP()
Returns true if this session is UDP |
protected void |
printSessionStart()
Displays the sesion startup message. |
protected void |
printSessionTerminated(long deltaMS)
Displays the sesion startup message. |
void |
sessionStarted(java.net.InetAddress inetAddr,
boolean isDuplex,
boolean isText)
Called when the session has started |
void |
sessionTerminated(java.lang.Throwable err,
long readCount,
long writeCount)
Callback just before the session is terminated |
static void |
SetDebugMode(boolean debug)
Sets the global debug mode |
void |
setPromptEnabled(boolean enable)
Sets the prompt enabled state |
void |
setSavedEventCount(int count)
Sets the event count state to the specified value |
void |
setSessionInfo(ServerSocketThread.SessionInfo sessionInfo)
Sets the session info handler |
void |
setTerminateSession()
Sets the terminate-session state to true |
void |
setTerminateSession(boolean term)
Sets the terminate-session state to the specified value |
boolean |
tcpWrite(byte[] data)
Write bytes to TCP output stream |
boolean |
terminateSession()
Callback to determine if the current session should be terminated |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PACKET_LEN_LINE_TERMINATOR
public static final int PACKET_LEN_END_OF_STREAM
public static final java.util.TimeZone GMT_Timezone
Constructor Detail |
---|
public AbstractClientPacketHandler(java.lang.String name)
Method Detail |
---|
public static void SetDebugMode(boolean debug)
public static boolean GetDebugMode()
public static boolean IsDebugMode()
public java.lang.String getName()
public long getSequenceID()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public void setSessionInfo(ServerSocketThread.SessionInfo sessionInfo)
setSessionInfo
in interface ClientPacketHandler
sessionInfo
- An implementation of the ServerSocketThread.SessionInfo interfacepublic ServerSocketThread.SessionInfo getSessionInfo()
getSessionInfo
in interface ClientPacketHandler
public java.lang.String getThreadName()
public int getLocalPort()
public int getRemotePort()
public void setPromptEnabled(boolean enable)
setPromptEnabled
in interface ClientPacketHandler
enable
- True to enable prompt, false to disablepublic boolean getPromptEnabled()
getPromptEnabled
in interface ClientPacketHandler
public boolean tcpWrite(byte[] data)
tcpWrite
in interface ClientPacketHandler
data
- The data bytes to write
public void sessionStarted(java.net.InetAddress inetAddr, boolean isDuplex, boolean isText)
sessionStarted
in interface ClientPacketHandler
inetAddr
- The host IP addressisDuplex
- True if the connection is TCPisText
- True if the connection is textprotected void printSessionStart()
public boolean equalsSessionID(java.lang.String sessionID)
equalsSessionID
in interface ClientPacketHandler
sessionID
- The session ID to test (specifying null should always return false)
protected java.lang.String getSessionID()
public long getSessionStartTimeMS()
public long getSessionStartTime()
protected boolean isTextPackets()
public boolean isDuplex()
public boolean isTCP()
public boolean isUDP()
public boolean isInputStream()
public java.lang.String getSessionType()
public java.net.InetAddress getInetAddress()
public java.lang.String getHostAddress()
public boolean hasHostAddress()
public java.lang.String getIPAddress()
public boolean hasIPAddress()
public void setSavedEventCount(int count)
public void clearSavedEventCount()
public void incrementSavedEventCount()
public boolean hasSavedEvents()
public int getSavedEventCount()
public int getResponsePort()
getResponsePort
in interface ClientPacketHandler
public int getMinimumPacketLength()
getMinimumPacketLength
in interface ClientPacketHandler
public int getMaximumPacketLength()
getMaximumPacketLength
in interface ClientPacketHandler
public byte[] getInitialPacket() throws java.lang.Exception
getInitialPacket
in interface ClientPacketHandler
java.lang.Exception
public byte[] getFinalPacket(boolean hasError) throws java.lang.Exception
getFinalPacket
in interface ClientPacketHandler
java.lang.Exception
public int getActualPacketLength(byte[] packet, int packetLen)
getActualPacketLength
in interface ClientPacketHandler
public abstract byte[] getHandlePacket(byte[] cmd) throws java.lang.Exception
getHandlePacket
in interface ClientPacketHandler
cmd
- The packet
java.lang.Exception
public void idleTimeoutInterrupt()
ServerSocketThread.setMinimuTimeoutIntervalMS
"
idleTimeoutInterrupt
in interface ClientPacketHandler
public void forceCloseTCPSession()
forceCloseTCPSession
in interface ClientPacketHandler
public void setTerminateSession(boolean term)
public void setTerminateSession()
setTerminateSession
in interface ClientPacketHandler
public void clearTerminateSession()
public boolean getTerminateSession()
getTerminateSession
in interface ClientPacketHandler
public boolean terminateSession()
terminateSession
in interface ClientPacketHandler
public void sessionTerminated(java.lang.Throwable err, long readCount, long writeCount)
sessionTerminated
in interface ClientPacketHandler
protected void printSessionTerminated(long deltaMS)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |