Package io.fluxcapacitor.javaclient.web
Class SocketResponse
java.lang.Object
io.fluxcapacitor.javaclient.web.SocketResponse
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:
success(long, Object)
— wraps a successful response valueerror(long, String)
— represents an error condition for the given request
Note: In most cases, SocketRequest
s and SocketResponse
s 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(Type type) Deserializes theresult
JSON node into an object of the given type.static SocketResponse
Creates aSocketResponse
representing a failed request.static SocketResponse
Creates aSocketResponse
representing a successful response.
-
Constructor Details
-
SocketResponse
public SocketResponse()
-
-
Method Details
-
success
Creates aSocketResponse
representing a successful response.- Parameters:
requestId
- the ID of the corresponding requestresponse
- the response object to serialize- Returns:
- a successful
SocketResponse
-
error
Creates aSocketResponse
representing a failed request.- Parameters:
requestId
- the ID of the corresponding requesterror
- an error message explaining the failure- Returns:
- an error
SocketResponse
-
deserialize
Deserializes theresult
JSON node into an object of the given type.- Parameters:
type
- the target type to convert the result into- Returns:
- the deserialized object
-