Package io.openems.common.websocket
Class WsData
java.lang.Object
io.openems.common.websocket.WsData
Objects of this class are used to store additional data with websocket
connections of WebSocketClient and WebSocketServer.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
This method is called on close of the parent websocket.org.java_websocket.WebSocket
Gets the WebSocket.void
handleJsonrpcResponse
(JsonrpcResponse response) Handles a JSON-RPC response by completing the previously registers request Future.void
send
(JsonrpcNotification notification) Sends a JSON-RPC Notification to a WebSocket.send
(JsonrpcRequest request) Sends a JSON-RPC request to a Websocket and registers a callback.void
setWebsocket
(org.java_websocket.WebSocket ws) Sets the WebSocket.abstract String
toString()
Provides a specific toString method.
-
Constructor Details
-
WsData
public WsData()
-
-
Method Details
-
dispose
public void dispose()This method is called on close of the parent websocket. Use it to release blocked resources. -
setWebsocket
public void setWebsocket(org.java_websocket.WebSocket ws) Sets the WebSocket.- Parameters:
ws
- the WebSocket instance
-
getWebsocket
public org.java_websocket.WebSocket getWebsocket()Gets the WebSocket. Possibly null!- Returns:
- the WebSocket instance
-
send
public CompletableFuture<JsonrpcResponseSuccess> send(JsonrpcRequest request) throws OpenemsError.OpenemsNamedException Sends a JSON-RPC request to a Websocket and registers a callback.- Parameters:
request
- the JSON-RPC Request- Returns:
- a promise for a successful JSON-RPC Response
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
send
Sends a JSON-RPC Notification to a WebSocket.- Parameters:
notification
- the JSON-RPC Notification- Throws:
OpenemsException
- on error
-
handleJsonrpcResponse
public void handleJsonrpcResponse(JsonrpcResponse response) throws OpenemsError.OpenemsNamedException Handles a JSON-RPC response by completing the previously registers request Future.- Parameters:
response
- the JSON-RPC Response- Throws:
OpenemsError.OpenemsNamedException
- on error
-
toString
Provides a specific toString method.
-