Class SocketResponse

java.lang.Object
io.fluxcapacitor.javaclient.web.SocketResponse

public class SocketResponse extends Object
Represents a response to a SocketRequest sent over a WebSocket session.

Each SocketResponse is associated with a requestId that matches it to the originating request. The response either contains a successful result as a JsonNode, or an error message indicating failure.

SocketResponse instances are typically generated via the static factory methods:

Note: In most cases, SocketRequests and SocketResponses are created and handled automatically by the SocketSession. Developers working within a Flux Capacitor system typically do not need to construct them manually. However, understanding their format becomes important when integrating with non-Flux systems—such as a browser-based UI—over WebSocket. In such scenarios, this class defines the structure of a response expected by a Flux client.

See Also:
  • Constructor Details

    • SocketResponse

      public SocketResponse()
  • Method Details

    • success

      public static SocketResponse success(long requestId, Object response)
      Creates a SocketResponse representing a successful response.
      Parameters:
      requestId - the ID of the corresponding request
      response - the response object to serialize
      Returns:
      a successful SocketResponse
    • error

      public static SocketResponse error(long requestId, String error)
      Creates a SocketResponse representing a failed request.
      Parameters:
      requestId - the ID of the corresponding request
      error - an error message explaining the failure
      Returns:
      an error SocketResponse
    • deserialize

      public Object deserialize(Type type)
      Deserializes the result JSON node into an object of the given type.
      Parameters:
      type - the target type to convert the result into
      Returns:
      the deserialized object