Package eu.ill.webx.transport
Class Transport
java.lang.Object
eu.ill.webx.transport.Transport
Wraps all ZMQ sockets into a single interface.
Each WebX Host uses an individual Transport to communicate with the server.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect(String hostname, int port, int socketTimeoutMs, boolean isStandalone, MessageSubscriber.MessageHandler messageHandler) Starts the connection to the different ZQM sockets of the server.voidDisconnects all ZMQ sockets and waits for any associated threads to terminate.booleanReturns true if connectedvoidsendInstruction(byte[] instructionData) Sends an instruction to the WebX serversendRequest(String request) 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 notstartSession(WebXClientConfiguration configuration) Sends a request to the session channel to start a new session with connection credentials
-
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 hostport- the port for the Client Connector on the host (other ports are obtained from here)socketTimeoutMs- the timeout in milliseconds for socket communicationisStandalone- specified whether the server has a WebX Engine running in standalone modemessageHandler- 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
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
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
-