Package com.ultikits.ultitools.utils
Class AgentProtocol.LiveChannel
java.lang.Object
com.ultikits.ultitools.utils.AgentProtocol.LiveChannel
- All Implemented Interfaces:
CloudChannel
- Enclosing class:
AgentProtocol
The live channel: the framed channel, with the outbound capability gate in front.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanbooleanisOpen()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.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.sendTracked(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.sendTracked(String type, com.google.gson.JsonObject payload, Consumer<String> beforeHandOff) Sends likeCloudChannel.sendTracked(String, JsonObject), but hands the envelope id tobeforeHandOffbefore the frame reaches the socket.
-
Constructor Details
-
LiveChannel
private LiveChannel()
-
-
Method Details
-
blocked
-
isOpen
public boolean isOpen()Description copied from interface:CloudChannelReports protocol readiness, not merely whether the socket is connected.- Specified by:
isOpenin interfaceCloudChannel- Returns:
- true only after an accepted welcome and before the connection closes
-
limits
Description copied from interface:CloudChannelReturns the current connection's accepted limits, or defaults before welcome.- Specified by:
limitsin interfaceCloudChannel- Returns:
- the immutable limits snapshot
-
send
Description copied from interface:CloudChannelSends a message with a fresh id and timestamp, without a replyTo field.- Specified by:
sendin interfaceCloudChannel- 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
-
sendTracked
Description copied from interface:CloudChannelSends 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
CloudChannel.send(java.lang.String, com.google.gson.JsonObject).- Specified by:
sendTrackedin interfaceCloudChannel- 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
-
sendTracked
public String sendTracked(String type, com.google.gson.JsonObject payload, Consumer<String> beforeHandOff) Description copied from interface:CloudChannelSends likeCloudChannel.sendTracked(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.- Specified by:
sendTrackedin interfaceCloudChannel- 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
-
reply
Description copied from interface:CloudChannelSends a correlated reply with a fresh id and timestamp.- Specified by:
replyin interfaceCloudChannel- 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
-
replyOk
Description copied from interface:CloudChannelReplies with an OpOutcome payload containingstatus: okand data.- Specified by:
replyOkin interfaceCloudChannel- 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
public boolean replyOk(String replyTo, String type, com.google.gson.JsonElement data, String messageOrNull) Description copied from interface:CloudChannelReplies 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.
- Specified by:
replyOkin interfaceCloudChannel- 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
-
replyPartial
public boolean replyPartial(String replyTo, String type, com.google.gson.JsonElement data, String codeOrNull, String messageOrNull) Description copied from interface:CloudChannelReplies withstatus: partial; only result types declaring partial allow this.- Specified by:
replyPartialin interfaceCloudChannel- 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
public boolean replyError(String replyTo, String type, String code, String message, com.google.gson.JsonObject detailsOrNull) Description copied from interface:CloudChannelReplies with code, message and optional details. Result types includestatus: error; the genericerrortype omits status.- Specified by:
replyErrorin interfaceCloudChannel- 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
-