Class AgentProtocol.LiveChannel

java.lang.Object
com.ultikits.ultitools.utils.AgentProtocol.LiveChannel
All Implemented Interfaces:
CloudChannel
Enclosing class:
AgentProtocol

private final class AgentProtocol.LiveChannel extends Object implements CloudChannel
The live channel: the framed channel, with the outbound capability gate in front.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
     
    boolean
    Reports protocol readiness, not merely whether the socket is connected.
    Returns the current connection's accepted limits, or defaults before welcome.
    boolean
    reply(String replyTo, String type, com.google.gson.JsonObject payload)
    Sends a correlated reply with a fresh id and timestamp.
    boolean
    replyError(String replyTo, String type, String code, String message, com.google.gson.JsonObject detailsOrNull)
    Replies with code, message and optional details.
    boolean
    replyOk(String replyTo, String type, com.google.gson.JsonElement data)
    Replies with an OpOutcome payload containing status: ok and data.
    boolean
    replyOk(String replyTo, String type, com.google.gson.JsonElement data, String messageOrNull)
    Replies with an OpOutcome payload containing status: ok, data and an optional message, for result types whose ok variant declares one.
    boolean
    replyPartial(String replyTo, String type, com.google.gson.JsonElement data, String codeOrNull, String messageOrNull)
    Replies with status: partial; only result types declaring partial allow this.
    boolean
    send(String type, com.google.gson.JsonObject payload)
    Sends 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 like CloudChannel.sendTracked(String, JsonObject), but hands the envelope id to beforeHandOff before the frame reaches the socket.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LiveChannel

      private LiveChannel()
  • Method Details

    • blocked

      private boolean blocked(String type)
    • isOpen

      public boolean isOpen()
      Description copied from interface: CloudChannel
      Reports protocol readiness, not merely whether the socket is connected.
      Specified by:
      isOpen in interface CloudChannel
      Returns:
      true only after an accepted welcome and before the connection closes
    • limits

      public CloudLimits limits()
      Description copied from interface: CloudChannel
      Returns the current connection's accepted limits, or defaults before welcome.
      Specified by:
      limits in interface CloudChannel
      Returns:
      the immutable limits snapshot
    • send

      public boolean send(String type, com.google.gson.JsonObject payload)
      Description copied from interface: CloudChannel
      Sends a message with a fresh id and timestamp, without a replyTo field.
      Specified by:
      send in interface CloudChannel
      Parameters:
      type - a registered message type that does not require replyTo
      payload - the schema-valid message payload
      Returns:
      true if the requested frame was handed to the socket
    • sendTracked

      public String sendTracked(String type, com.google.gson.JsonObject payload)
      Description copied from interface: CloudChannel
      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 CloudChannel.send(java.lang.String, com.google.gson.JsonObject).

      Specified by:
      sendTracked in interface CloudChannel
      Parameters:
      type - a registered message type that does not require replyTo
      payload - 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: CloudChannel
      Sends like CloudChannel.sendTracked(String, JsonObject), but hands the envelope id to beforeHandOff before 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:
      sendTracked in interface CloudChannel
      Parameters:
      type - a registered message type that does not require replyTo
      payload - the schema-valid message payload
      beforeHandOff - 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

      public boolean reply(String replyTo, String type, com.google.gson.JsonObject payload)
      Description copied from interface: CloudChannel
      Sends a correlated reply with a fresh id and timestamp.
      Specified by:
      reply in interface CloudChannel
      Parameters:
      replyTo - the request's ULID, never null
      type - a registered message type that allows replyTo
      payload - the schema-valid reply payload
      Returns:
      true if the requested reply was handed to the socket
    • replyOk

      public boolean replyOk(String replyTo, String type, com.google.gson.JsonElement data)
      Description copied from interface: CloudChannel
      Replies with an OpOutcome payload containing status: ok and data.
      Specified by:
      replyOk in interface CloudChannel
      Parameters:
      replyTo - the request's ULID
      type - the result message type
      data - 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: CloudChannel
      Replies with an OpOutcome payload containing status: 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:
      replyOk in interface CloudChannel
      Parameters:
      replyTo - the request's ULID
      type - the result message type
      data - result data matching that type's schema, including JSON null where allowed
      messageOrNull - 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: CloudChannel
      Replies with status: partial; only result types declaring partial allow this.
      Specified by:
      replyPartial in interface CloudChannel
      Parameters:
      replyTo - the request's ULID
      type - the result message type
      data - partial result data matching that type's schema
      codeOrNull - an allowed result code, or null to omit it
      messageOrNull - 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: CloudChannel
      Replies with code, message and optional details. Result types include status: error; the generic error type omits status.
      Specified by:
      replyError in interface CloudChannel
      Parameters:
      replyTo - the request's ULID
      type - the result message type or error
      code - an error code allowed for that type
      message - a safe diagnostic, never a credential or raw exception message
      detailsOrNull - schema-valid details, or null to omit them
      Returns:
      true if the requested reply was handed to the socket