Class LogicalChannel

java.lang.Object
cl.netswitch.lib.client.LogicalChannel
All Implemented Interfaces:
AutoCloseable

public final class LogicalChannel extends Object implements 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 Details

    • sendRequest

      public Message sendRequest(String destination, Serializable data) throws Exception
      Sends a request message to a destination 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 destination switch: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 - if destination is null.
      Exception - if another error occurs.
    • sendRequest

      public Message sendRequest(String destination, Serializable data, int timeout) throws SocketTimeoutException, Exception
      Sends a request message to a destination and then blocks waiting for the reply message for at most timeout milliseconds. The value of destination 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 optional SwitchName is not specified, the message is sent to the connected switch. ServerName is the name of a server, a listener or a connector. The optional ServiceName 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
      Argument timeout specifies the amount of time to wait for the synchronous reply message.
      Parameters:
      destination - the request destination switch: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 - if destination is null.
      IllegalArgumentException - if timeout is negative.
      IllegalStateException - if the logical channel is closed.
      SocketTimeoutException - if timeout 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 the try-with-resources statement.
      Specified by:
      close in interface AutoCloseable