Package co.ecg.alpaca.toolkit.messaging
Class OCSClient
java.lang.Object
co.ecg.alpaca.toolkit.messaging.OCSClient
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Connects to the specified Host and Port.void
Closes the current connection.long
getName()
boolean
isClosed()
Returns true iff the OCS socket is currently closed.void
This limits the number of packets per second that can be sent to the BroadWorksServer.sendMessage
(String message) Send a message through the OCS socket using the default timeout as specified in the Alpaca properties file.sendMessage
(String message, long timeout) Send a message through the OCS socket specifying the timeout.void
-
Constructor Details
-
OCSClient
-
-
Method Details
-
getName
-
setName
-
getLastRequest
public long getLastRequest() -
connect
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 connectport
- The port on the host to connect- Throws:
IOException
- Thrown if a fatal IO error occurs
-
disconnect
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
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
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.
-