Package com.iizix.jetty
Class JettyClientWebSocketInstance
java.lang.Object
com.iizix.jetty.JettyClientWebSocketInstance
The client class for communication with a remote server over (secured) WebSocket using the IIZI reconnectable transactional processing.
- Author:
- Christopher Mindus
Constructor Summary
ConstructorDescriptionJettyClientWebSocketInstance
(PropFactory propFactory, String host, int port, boolean isSecure, String wsURI, boolean isVerbose, IClientInstanceListener clientListener) Constructor.Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
Connects to the WebSocket URI with or without SSL.void
connect
(boolean noTimeouts) Connects to the WebSocket URI with or without SSL.boolean
dispose()
Disposes of this instance and closes the communication session (if opened).Gets the info string of this session.Gets the session information instance.getState()
Gets the state as a String.boolean
Checks if connected.boolean
Checks if disconnected.boolean
Gets the verbose flag.int
sendBinaryData
(int id, String descr, byte[] data) Sends a block of binary data to the remote party.void
setVerbose
(boolean isVerbose) Sets the verbose flag, also used for new clients.void
setWriteCacheParams
(int minLength, int maxLength, int cacheCount) Sets the parameters for the write cache: minLength, maxLength, cacheCount.toString()
The String representation as "host:port - description".
Constructor Details
JettyClientWebSocketInstance
public JettyClientWebSocketInstance(PropFactory propFactory, String host, int port, boolean isSecure, String wsURI, boolean isVerbose, IClientInstanceListener clientListener) throws IOException, UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, NoSuchProviderException, IllegalArgumentException Constructor.- Parameters:
propFactory
- The property factory.host
- The host name or address.port
- The port number.isSecure
- The secure communication flags.wsURI
- The relative WebSocket URI starting with "/" (normally ending with .ws [unsecure] or .wss [secure]).isVerbose
- The verbose flag.clientListener
- The client listener.- Throws:
IOException
- For I/O errors.NoSuchProviderException
KeyStoreException
CertificateException
NoSuchAlgorithmException
KeyManagementException
UnrecoverableKeyException
IllegalArgumentException
Method Details
isVerbose
public boolean isVerbose()Gets the verbose flag.- Returns:
- The verbose output flag on console.
setVerbose
public void setVerbose(boolean isVerbose) Sets the verbose flag, also used for new clients.- Parameters:
isVerbose
- The verbose output flag on console.
setWriteCacheParams
public void setWriteCacheParams(int minLength, int maxLength, int cacheCount) Sets the parameters for the write cache: minLength, maxLength, cacheCount. This call must be done before connecting.- Parameters:
minLength
- The minimum length for caching, 7 is the smallest value.maxLength
- The maximum length for caching, normally 80 or so (maximum 1024).cacheCount
- The count should normally be larger than 200 and smaller than 1000 (range is 10 to 2048), if zero, cache is disabled.- Throws:
IllegalArgumentException
- If arguments are not valid.
isConnected
public boolean isConnected()Checks if connected.- Returns:
- true if connected, false otherwise.
isDisconnected
public boolean isDisconnected()Checks if disconnected.- Returns:
- true if disconnected, false otherwise.
getState
Gets the state as a String.- Returns:
- "Connecting", "Connected", "Disconnecting" or "Disconnected".
connect
Connects to the WebSocket URI with or without SSL.- Throws:
IllegalStateException
- If already connected or connecting.IOException
- For communication problems.
connect
Connects to the WebSocket URI with or without SSL.- Parameters:
noTimeouts
- Connect with debug = no timeouts! This way we can set breakpoints in Eclipse.- Throws:
IllegalStateException
- If already connected or connecting.IOException
- For communication problems.
dispose
public boolean dispose()Disposes of this instance and closes the communication session (if opened). The web socket connection is closed with the close code "1000" = "Normal close". This root property is disposed of.- Returns:
- true for success, false if already disposed of.
sendBinaryData
Sends a block of binary data to the remote party.- Parameters:
id
- The ID of the reply local ID for error or success reply.descr
- Short description of the data.data
- The data.- Returns:
- The byte size sent.
- Throws:
EOFException
- If connection is closed.IOException
- For send failures.
getSessionInfo
Gets the session information instance.- Returns:
- The SessionInfo.
getInfoString
Gets the info string of this session.- Returns:
- Same as
SessionInfo.getConnectionIDString(info)
.
toString
The String representation as "host:port - description".