Package com.iizix.comm.client
Class ClientInstance
java.lang.Object
com.iizix.comm.client.ClientInstance
The client class for communication with a remote server over (secured) WebSocket using the IIZI reconnectable transactional processing.
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescription- ClientInstance- (PropFactory propFactory, String host, int port, String wsURI, SSLCommProps sslProps, boolean isVerbose, IClientInstanceListener clientListener) Constructor.
- Method SummaryModifier and TypeMethodDescription- void- 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.- booleanChecks if connected.- booleanChecks if disconnected.- booleanGets 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- ClientInstancepublic ClientInstance- (PropFactory propFactory, String host, int port, String wsURI, SSLCommProps sslProps, boolean isVerbose, IClientInstanceListener clientListener) throws IOException, UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, NoSuchProviderException Constructor.- Parameters:
- propFactory- The property factory.
- host- The host name or address.
- port- The port number.
- wsURI- The relative WebSocket URI starting with "/" (normally ending with .ws [unsecure] or .wss [secure]).
- sslProps- The SSL properties, null for not secure.
- isVerbose- The verbose flag.
- clientListener- The client listener.
- Throws:
- IOException- For I/O errors.
- NoSuchProviderException
- KeyStoreException
- CertificateException
- NoSuchAlgorithmException
- KeyManagementException
- UnrecoverableKeyException
 
 
- Method Details- isVerbosepublic boolean isVerbose()Gets the verbose flag.- Returns:
- The verbose output flag on console.
 
- setVerbosepublic void setVerbose- (boolean isVerbose) Sets the verbose flag, also used for new clients.- Parameters:
- isVerbose- The verbose output flag on console.
 
- setWriteCacheParamspublic 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.
 
- isConnectedpublic boolean isConnected()Checks if connected.- Returns:
- true if connected, false otherwise.
 
- isDisconnectedpublic boolean isDisconnected()Checks if disconnected.- Returns:
- true if disconnected, false otherwise.
 
- getStateGets the state as a String.- Returns:
- "Connecting", "Connected", "Disconnecting" or "Disconnected".
 
- connectConnects to the WebSocket URI with or without SSL.- Throws:
- IllegalStateException- If already connected or connecting.
- IOException- For communication problems.
 
- connectConnects 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.
 
- disposepublic 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.
 
- sendBinaryDataSends 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.
 
- getSessionInfoGets the session information instance.- Returns:
- The SessionInfo.
 
- getInfoStringGets the info string of this session.- Returns:
- Same as SessionInfo.getConnectionIDString(info).
 
- toStringThe String representation as "host:port - description".