Interface CloudChannel
- All Known Implementing Classes:
AgentProtocol.LiveChannel, FramedChannel
@Internal
public interface CloudChannel
Frames and sends UltiCloud protocol v2 messages; internal, not for module use.
Sending methods return true only when the requested frame was handed to the socket,
not when the gateway acknowledged it. False means the requested frame was not handed
off: the channel may be closed, the socket may refuse it, or the frame may be too large.
An oversized reply may instead send a correlated error payload_too_large
and still return false. Payloads must already match their message schemas.
- Since:
- 6.3.1
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisOpen()Reports protocol readiness, not merely whether the socket is connected.limits()Returns the current connection's accepted limits, or defaults before welcome.booleanSends a correlated reply with a fresh id and timestamp.booleanreplyError(String replyTo, String type, String code, String message, com.google.gson.JsonObject detailsOrNull) Replies with code, message and optional details.booleanReplies with an OpOutcome payload containingstatus: okand data.default booleanReplies with an OpOutcome payload containingstatus: ok, data and an optional message, for result types whose ok variant declares one.booleanreplyPartial(String replyTo, String type, com.google.gson.JsonElement data, String codeOrNull, String messageOrNull) Replies withstatus: partial; only result types declaring partial allow this.booleanSends a message with a fresh id and timestamp, without a replyTo field.default StringsendTracked(String type, com.google.gson.JsonObject payload) Sends a message with a fresh id and timestamp, without a replyTo field, and reports the envelope id it used so the caller can correlate a later reply to this frame.default StringsendTracked(String type, com.google.gson.JsonObject payload, Consumer<String> beforeHandOff) Sends likesendTracked(String, JsonObject), but hands the envelope id tobeforeHandOffbefore the frame reaches the socket.
-
Method Details
-
isOpen
boolean isOpen()Reports protocol readiness, not merely whether the socket is connected.- Returns:
- true only after an accepted welcome and before the connection closes
-
limits
CloudLimits limits()Returns the current connection's accepted limits, or defaults before welcome.- Returns:
- the immutable limits snapshot
-
send
Sends a message with a fresh id and timestamp, without a replyTo field.- Parameters:
type- a registered message type that does not require replyTopayload- the schema-valid message payload- Returns:
- true if the requested frame was handed to the socket
- Throws:
IllegalArgumentException- if the type is unknown or requires replyTo
-
sendTracked
Sends a message with a fresh id and timestamp, without a replyTo field, and reports the envelope id it used so the caller can correlate a later reply to this frame.The default implementation cannot report the id and refuses; channels used by the framework implement it so the id and the send path cannot diverge from
send(String, JsonObject).- Parameters:
type- a registered message type that does not require replyTopayload- the schema-valid message payload- Returns:
- the envelope id of the frame handed to the socket, or null when nothing was handed off, including a closed channel or an oversized frame
- Throws:
IllegalArgumentException- if the type is unknown or requires replyToUnsupportedOperationException- if the channel cannot report the id it used- Since:
- 6.3.1
-
sendTracked
default String sendTracked(String type, com.google.gson.JsonObject payload, Consumer<String> beforeHandOff) Sends likesendTracked(String, JsonObject), but hands the envelope id tobeforeHandOffbefore the frame reaches the socket. A caller that correlates the reply registers its pending entry there, so a reply processed on another thread can never arrive before the entry exists. When the result is null the frame was not handed off and the caller rolls its registration back; the hook may then have run or not.- Parameters:
type- a registered message type that does not require replyTopayload- the schema-valid message payloadbeforeHandOff- receives the envelope id before the hand-off; must not block or throw- Returns:
- the envelope id of the frame handed to the socket, or null when nothing was handed off
- Throws:
IllegalArgumentException- if the type is unknown or requires replyToUnsupportedOperationException- if the channel cannot report the id it used- Since:
- 6.3.1
-
reply
Sends a correlated reply with a fresh id and timestamp.- Parameters:
replyTo- the request's ULID, never nulltype- a registered message type that allows replyTopayload- the schema-valid reply payload- Returns:
- true if the requested reply was handed to the socket
- Throws:
IllegalArgumentException- if the type or correlation id is invalid
-
replyOk
Replies with an OpOutcome payload containingstatus: okand data.- Parameters:
replyTo- the request's ULIDtype- the result message typedata- result data matching that type's schema, including JSON null where allowed- Returns:
- true if the requested reply was handed to the socket
-
replyOk
default boolean replyOk(String replyTo, String type, com.google.gson.JsonElement data, String messageOrNull) Replies with an OpOutcome payload containingstatus: ok, data and an optional message, for result types whose ok variant declares one.A channel that cannot carry the message refuses instead of silently dropping it, so a caller never believes an explanation reached the panel when it did not.
- Parameters:
replyTo- the request's ULIDtype- the result message typedata- result data matching that type's schema, including JSON null where allowedmessageOrNull- a safe result message (1..500 characters), or null to omit it- Returns:
- true if the requested reply was handed to the socket
- Throws:
UnsupportedOperationException- if the channel cannot send an ok message- Since:
- 6.3.1
-
replyPartial
boolean replyPartial(String replyTo, String type, com.google.gson.JsonElement data, String codeOrNull, String messageOrNull) Replies withstatus: partial; only result types declaring partial allow this.- Parameters:
replyTo- the request's ULIDtype- the result message typedata- partial result data matching that type's schemacodeOrNull- an allowed result code, or null to omit itmessageOrNull- a safe result message, or null to omit it- Returns:
- true if the requested reply was handed to the socket
-
replyError
boolean replyError(String replyTo, String type, String code, String message, com.google.gson.JsonObject detailsOrNull) Replies with code, message and optional details. Result types includestatus: error; the genericerrortype omits status.- Parameters:
replyTo- the request's ULIDtype- the result message type orerrorcode- an error code allowed for that typemessage- a safe diagnostic, never a credential or raw exception messagedetailsOrNull- schema-valid details, or null to omit them- Returns:
- true if the requested reply was handed to the socket
-