@WebSocket public class WebSocketConnection extends java.lang.Object implements AEConnection, java.io.Closeable
onConnect(org.eclipse.jetty.websocket.api.Session), onClose(org.eclipse.jetty.websocket.api.Session, int, java.lang.String),
onMessage(String), onMessage(byte[], int, int),
onError(java.lang.Throwable), onReceiveFrame(org.eclipse.jetty.websocket.api.Session, org.eclipse.jetty.websocket.api.extensions.Frame))
can only be called internally.| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection to the UC4 Server.
|
ConnectionAttributes |
getSessionInfo()
Returns information about the current UC4 Session.
|
void |
onClose(org.eclipse.jetty.websocket.api.Session session,
int statusCode,
java.lang.String reason) |
void |
onConnect(org.eclipse.jetty.websocket.api.Session wsSession)
Internal use only
|
void |
onError(java.lang.Throwable cause)
Internal use only
|
void |
onMessage(byte[] buf,
int offset,
int length)
Internal use only
WebSocket method to receive binary messages
|
void |
onMessage(java.lang.String xml)
Internal use only
WebSocket method to receive xml messages
|
void |
onReceiveFrame(org.eclipse.jetty.websocket.api.Session session,
org.eclipse.jetty.websocket.api.extensions.Frame frame)
Internal use only
WebSocket method when receiving a Frame - if it is a ping or pong message, a debug message gets written
|
java.lang.String |
sendRequest(XMLRequest sendableMessage,
IResponseHandler handler)
Sends an message to the UC4 Server.
|
void |
sendRequestAndWait(XMLRequest sendableMessage)
Sends a message to the UC4 Server and waits for the response.
|
java.lang.String |
toString() |
public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic void sendRequestAndWait(XMLRequest sendableMessage) throws java.io.IOException
When a request is sent with this method, before further processing of the response, the message
of the response (see XMLRequest.getMessageBox()) has to be always checked for any error.
Only if this is empty the processing of the response can continue.
If an error is present, proper error handling has to be implemented on the calling side.
Processing the unsuccessful response might get undefined results!
sendRequestAndWait in interface AEConnectionsendableMessage - XML requestjava.io.IOException - If an I/O error occursTimeoutException - if a timeout was and a response was not received in the API within the specified timepublic java.lang.String sendRequest(XMLRequest sendableMessage, IResponseHandler handler) throws java.io.IOException
After the request is sent to the UC4 Server the method call returns immediately. When the response to this request arrives the IResponseHandler will be called.
This method does not support creating folders (request CreateObject with type FOLD). Use the method sendRequestAndWait() in order to create a new folder.sendRequest in interface AEConnectionsendableMessage - Object which implements the XMLRequest Interfacehandler - Response Handlerjava.io.IOException - If an I/O error occurspublic ConnectionAttributes getSessionInfo()
getSessionInfo in interface AEConnectionpublic java.lang.String toString()
toString in class java.lang.Object@OnWebSocketConnect public void onConnect(org.eclipse.jetty.websocket.api.Session wsSession)
wsSession - WebSocket session@OnWebSocketClose
public void onClose(org.eclipse.jetty.websocket.api.Session session,
int statusCode,
java.lang.String reason)
session - sessionstatusCode - status code, not usedreason - reason for close, not used@OnWebSocketError public void onError(java.lang.Throwable cause)
cause - Error cause@OnWebSocketMessage public void onMessage(java.lang.String xml)
xml - Received XML message@OnWebSocketFrame
public void onReceiveFrame(org.eclipse.jetty.websocket.api.Session session,
org.eclipse.jetty.websocket.api.extensions.Frame frame)
session - sessionframe - receivedFrame@OnWebSocketMessage
public void onMessage(byte[] buf,
int offset,
int length)
throws java.io.IOException
buf - Input messageoffset - Offsetlength - Lengthjava.io.IOException - In case of IO errors