Class LogicalChannel
java.lang.Object
cl.netswitch.lib.client.LogicalChannel
- All Implemented Interfaces:
AutoCloseable
Logical channel of a multiplexed communication
ClientChannel. Through
this channel, an application can send service requests to a switch server or
other custom made servers (see ServerChannel
for details about building custom servers).-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this resource, relinquishing any underlying resources.sendRequest(String destination, Serializable data) Sends a request message to adestinationand then blocks forever waiting for the reply message.sendRequest(String destination, Serializable data, int timeout) Sends a request message to adestinationand then blocks waiting for the reply message for at mosttimeoutmilliseconds.
-
Method Details
-
sendRequest
Sends a request message to adestinationand then blocks forever waiting for the reply message.This convenience method produces the same result as the following invocation:
sendRequest(destination, data, 0);- Parameters:
destination- the request destinationswitch:server.service.data- the data to include in the request message (can be null).- Returns:
- the reply message returned from the switch server.
- Throws:
NullPointerException- ifdestinationisnull.Exception- if another error occurs.
-
sendRequest
public Message sendRequest(String destination, Serializable data, int timeout) throws SocketTimeoutException, Exception Sends a request message to adestinationand then blocks waiting for the reply message for at mosttimeoutmilliseconds. The value ofdestinationmust have the following format:[SwitchName:]ServerName[.ServiceName]
where optional items are shown within"["and"]"brackets, and the characters":"and"."stand for themselves. If the optionalSwitchNameis not specified, the message is sent to the connected switch.ServerNameis the name of a server, a listener or a connector. The optionalServiceNameis the name of a service provided by the server, or the name of a channel of a listener. The following are examples of valid destinations:POS_DEVICE SWITCH.LOG_ERROR HUB:IMSER.ADD_CONTACT
Argumenttimeoutspecifies the amount of time to wait for the synchronous reply message.- Parameters:
destination- the request destinationswitch:server.service.data- the data to include in the request message (can be null).timeout- the maximum time to wait for a reply (in milliseconds).- Returns:
- the reply message returned from the switch server.
- Throws:
NullPointerException- ifdestinationisnull.IllegalArgumentException- iftimeoutis negative.IllegalStateException- if the logical channel is closed.SocketTimeoutException- iftimeoutexpired while waiting for reply.Exception- if another error occurs.
-
close
public void close()Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by thetry-with-resources statement.- Specified by:
closein interfaceAutoCloseable
-