Class Transport

java.lang.Object
eu.ill.webx.transport.Transport

public class Transport extends Object
Wraps all ZMQ sockets into a single interface. Each WebX Host uses an individual Transport to communicate with the server.
  • Constructor Details

    • Transport

      public Transport()
      Default constructor
  • Method Details

    • isConnected

      public boolean isConnected()
      Returns true if connected
      Returns:
      true if connected
    • connect

      public void connect(String hostname, int port, int socketTimeoutMs, boolean isStandalone, MessageSubscriber.MessageHandler messageHandler) throws WebXDisconnectedException
      Starts the connection to the different ZQM sockets of the server.
      Parameters:
      hostname - the WebX host
      port - the port for the Client Connector on the host (other ports are obtained from here)
      socketTimeoutMs - the timeout in milliseconds for socket communication
      isStandalone - specified whether the server has a WebX Engine running in standalone mode
      messageHandler - a handler for all incoming messages from the server
      Throws:
      WebXDisconnectedException - thrown in the connection fails
    • disconnect

      public void disconnect()
      Disconnects all ZMQ sockets and waits for any associated threads to terminate.
    • sendInstruction

      public void sendInstruction(byte[] instructionData)
      Sends an instruction to the WebX server
      Parameters:
      instructionData - the instruction data
    • sendRequest

      public SocketResponse sendRequest(String request) throws WebXDisconnectedException
      Sends a synchronous request to the server using either the client connector or session channel depending on whether the server is running in standalone or not
      Parameters:
      request - The string formatted request
      Returns:
      The Socket response
      Throws:
      WebXDisconnectedException - thrown if the communication fails or the server is not connected
    • startSession

      public String startSession(WebXClientConfiguration configuration) throws WebXDisconnectedException
      Sends a request to the session channel to start a new session with connection credentials
      Parameters:
      configuration - The configuration for the session (login, screen size and keyboard)
      Returns:
      The session Id string
      Throws:
      WebXDisconnectedException - thrown if the server is not running in standalone mode