Class OCSClient

java.lang.Object
co.ecg.alpaca.toolkit.messaging.OCSClient

@Component @Scope("prototype") public class OCSClient extends Object
OCSClient

Originally provided by Broadsoft. Edited for use in the Alpaca Library. The Request and Response are paired based upon ordering. This means that multiple requests sent through the same client risk contamination.

Author:
Matthew Keathley
  • Constructor Details

  • Method Details

    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getLastRequest

      public long getLastRequest()
    • connect

      public void connect(String host, int port) throws IOException
      Connects to the specified Host and Port. The Host name will be resolved but does not support multiple DNS records.
      Parameters:
      host - The host to connect
      port - The port on the host to connect
      Throws:
      IOException - Thrown if a fatal IO error occurs
    • disconnect

      public void disconnect() throws IOException
      Closes the current connection.
      Throws:
      IOException - Thrown if an issue occurs during disconnection.
    • packetLimit

      public void packetLimit()
      This limits the number of packets per second that can be sent to the BroadWorksServer. The number per second is set in the configuration. This call will cause the Thread to sleep until the BroadWorksServer can receive additional packets.
    • isClosed

      public boolean isClosed()
      Returns true iff the OCS socket is currently closed.
      Returns:
      Will return true if the OCS Socket is null or closed.
    • sendMessage

      public String sendMessage(String message) throws IOException, InterruptedException
      Send a message through the OCS socket using the default timeout as specified in the Alpaca properties file.
      Parameters:
      message - The message to send through the socket.
      Returns:
      The reply to the message.
      Throws:
      IOException - Thrown if there is a socket error.
      InterruptedException - Thrown if there is a synchronization issue.
    • sendMessage

      public String sendMessage(String message, long timeout) throws IOException, InterruptedException
      Send a message through the OCS socket specifying the timeout.
      Parameters:
      message - The message to send.
      timeout - The message response timeout in milliseconds.
      Returns:
      The reply to the message.
      Throws:
      IOException - Thrown if there is a socket error.
      InterruptedException - Thrown if there is a synchronization issue.