Class OCSSwitchboard

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

@Component @Scope("prototype") public class OCSSwitchboard extends Object
Author:
Matthew Keathley on 9/26/16.
  • Constructor Details

    • OCSSwitchboard

      @Autowired public OCSSwitchboard(LibraryProperties libraryProperties, org.springframework.context.ApplicationContext applicationContext, MessageDigestUtils messageDigestUtils)
  • Method Details

    • getLastRequestTime

      public long getLastRequestTime()
    • connect

      public void connect(BroadWorksServer broadWorksServer) throws BroadWorksServerException, IOException
      Throws:
      BroadWorksServerException
      IOException
    • isConnected

      public boolean isConnected()
      Returns if the OCSSwitchboard has at least 1 active OCSSocket
      Returns:
      True IFF the OCSBuffer is greater than 0
    • disconnect

      public void disconnect() throws IOException
      Disconnects all OCSClients in the Switchboard
      Throws:
      IOException - Thrown if an error occurs during close
    • sendMessage

      public Future<String> sendMessage(String message, long timeout)
      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.
      timeout - The message timeout in milliseconds.
      Returns:
      The reply to the message.
    • login

      public void login(String username, String password) throws BroadWorksLoginException, RequestException
      Performs the Login Procedure for each OCS client in the switchboard
      Parameters:
      username - The username to login as
      password - The password to login as
      Throws:
      BroadWorksLoginException - Thrown if the login fails for any reason.
      RequestException
    • performOCSLogin

      public static void performOCSLogin(String username, String password, BroadWorksServer broadWorksServer, OCSClient ocsClient, org.springframework.context.ApplicationContext applicationContext, MessageDigestUtils messageDigestUtils) throws RequestException, BroadWorksLoginException
      Performs the Login Procedure for a specific OCS client
      Parameters:
      username - The username to login as
      password - The password to login as
      ocsClient - The OCS client to login
      Throws:
      RequestException - Thrown if an error occurs generating login requests
      BroadWorksLoginException - Thrown if authentication fails