Class WsData

java.lang.Object
io.openems.common.websocket.WsData
Direct Known Subclasses:
DummyWsData, WsData, WsData, WsData, WsData, WsData

public abstract class WsData extends Object
Objects of this class are used to store additional data with websocket connections of WebSocketClient and WebSocketServer.
  • 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

      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

      public void send(JsonrpcNotification notification) throws OpenemsException
      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

      public abstract String toString()
      Provides a specific toString method.
      Overrides:
      toString in class Object
      Returns:
      a specific string for this instance