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 TypeMethodDescriptionvoid
close()
Closes this resource, relinquishing any underlying resources.sendRequest
(String destination, Serializable data) Sends a request message to adestination
and then blocks forever waiting for the reply message.sendRequest
(String destination, Serializable data, int timeout) Sends a request message to adestination
and then blocks waiting for the reply message for at mosttimeout
milliseconds.
-
Method Details
-
sendRequest
Sends a request message to adestination
and 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
- ifdestination
isnull
.Exception
- if another error occurs.
-
sendRequest
public Message sendRequest(String destination, Serializable data, int timeout) throws SocketTimeoutException, Exception Sends a request message to adestination
and then blocks waiting for the reply message for at mosttimeout
milliseconds. The value ofdestination
must have the following format:[SwitchName:]ServerName[.ServiceName]
where optional items are shown within"["
and"]"
brackets, and the characters":"
and"."
stand for themselves. If the optionalSwitchName
is not specified, the message is sent to the connected switch.ServerName
is the name of a server, a listener or a connector. The optionalServiceName
is 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
Argumenttimeout
specifies 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
- ifdestination
isnull
.IllegalArgumentException
- iftimeout
is negative.IllegalStateException
- if the logical channel is closed.SocketTimeoutException
- iftimeout
expired 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:
close
in interfaceAutoCloseable
-