Package co.ecg.alpaca.toolkit.messaging
Class OCSSwitchboard
java.lang.Object
co.ecg.alpaca.toolkit.messaging.OCSSwitchboard
- Author:
- Matthew Keathley on 9/26/16.
-
Constructor Summary
ConstructorsConstructorDescriptionOCSSwitchboard
(LibraryProperties libraryProperties, org.springframework.context.ApplicationContext applicationContext, MessageDigestUtils messageDigestUtils) -
Method Summary
Modifier and TypeMethodDescriptionvoid
connect
(BroadWorksServer broadWorksServer) void
Disconnects all OCSClients in the Switchboardlong
boolean
Returns if the OCSSwitchboard has at least 1 active OCSSocketvoid
Performs the Login Procedure for each OCS client in the switchboardstatic void
performOCSLogin
(String username, String password, BroadWorksServer broadWorksServer, OCSClient ocsClient, org.springframework.context.ApplicationContext applicationContext, MessageDigestUtils messageDigestUtils) Performs the Login Procedure for a specific OCS clientsendMessage
(String message, long timeout) Send a message through the OCS socket using the default timeout as specified in the Alpaca properties file.
-
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
Disconnects all OCSClients in the Switchboard- Throws:
IOException
- Thrown if an error occurs during close
-
sendMessage
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 aspassword
- 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 aspassword
- The password to login asocsClient
- The OCS client to login- Throws:
RequestException
- Thrown if an error occurs generating login requestsBroadWorksLoginException
- Thrown if authentication fails
-