Package eu.ill.webx.relay
Class WebXClient
java.lang.Object
eu.ill.webx.relay.WebXClient
Provides a connection point between specific web client and a session.
Messages from the WebXEngine are stored in the messageQueue and read manually from client applications (via the WebXTunnel).
-
Method Summary
Modifier and TypeMethodDescriptionReturns the client identifierbyte[]Blocking method, waiting for a message to be sent from the server.Returns the session IdbooleanReturns true if state is connectedvoidCalled by the session when the client is disconneted.voidonMessage(byte[] messageData) Called when a message from the server is destined to this client.voidsendInstruction(byte[] instructionData) Sends a message to the instruction publisher.
-
Method Details
-
getClientIdentifier
Returns the client identifier- Returns:
- the client identifier
-
getSessionId
Returns the session Id- Returns:
- the session Id
-
onDisconnected
public void onDisconnected()Called by the session when the client is disconneted. This sends a message to the message queue to unblock any calls that are active to the getMessage method -
isConnected
public boolean isConnected()Returns true if state is connected- Returns:
- true if state is connected
-
onMessage
public void onMessage(byte[] messageData) Called when a message from the server is destined to this client. Queues a new Message object- Parameters:
messageData- the raw message data
-
sendInstruction
public void sendInstruction(byte[] instructionData) Sends a message to the instruction publisher. The instruction data is prefixed with the session Id and client Id.- Parameters:
instructionData- the binary instruction data from the client
-
getMessage
public byte[] getMessage() throws WebXClientException, WebXConnectionInterruptException, WebXDisconnectedExceptionBlocking method, waiting for a message to be sent from the server. Messages from the server are queued by a separate thread.- Returns:
- the raw binary message from the engine
- Throws:
WebXClientException- thrown if the client is in errorWebXConnectionInterruptException- thrown if the connection is interruptedWebXDisconnectedException- thrown if disconnected
-