Class ClientInstance

java.lang.Object
com.iizix.comm.client.ClientInstance

public class ClientInstance extends Object
The client class for communication with a remote server over (secured) WebSocket using the IIZI reconnectable transactional processing.
Author:
Christopher Mindus
  • Constructor Details

  • 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

      public String getState()
      Gets the state as a String.
      Returns:
      "Connecting", "Connected", "Disconnecting" or "Disconnected".
    • connect

      public void connect() throws IOException
      Connects to the WebSocket URI with or without SSL.
      Throws:
      IllegalStateException - If already connected or connecting.
      IOException - For communication problems.
    • connect

      public void connect(boolean noTimeouts) throws IOException
      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

      public int sendBinaryData(int id, String descr, byte[] data) throws IOException
      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

      public SessionInfo getSessionInfo()
      Gets the session information instance.
      Returns:
      The SessionInfo.
    • getInfoString

      public String getInfoString()
      Gets the info string of this session.
      Returns:
      Same as SessionInfo.getConnectionIDString(info).
    • toString

      public String toString()
      The String representation as "host:port - description".
      Overrides:
      toString in class Object
      Returns:
      Same as SessionInfo.getConnectionIDString(info).