Class WebSocketTransport

java.lang.Object
ai.badmonkey.agentspaces.transport.http.WebSocketTransport
All Implemented Interfaces:
Transport, AutoCloseable

public final class WebSocketTransport extends Object
The ws binding (SRAD agentspaces-js §3.3; ISSUE-Websocket FR-1): one binary WebSocket message per frame over plain TCP, subprotocol aspace.1, path /aspace by default. The WebSocket analogue of tcp: for development, tests, and links behind a TLS terminator inside a trusted network; it attests nothing, so peers in the SESSION mode attest the connection in band (SPEC §5.6), and a node that requires attestation refuses it.
  • Field Details

  • Constructor Details

    • WebSocketTransport

      public WebSocketTransport()
  • Method Details

    • options

      public WebSocketTransport options(HttpOptions options)
      Sets the options; valid before the first dial or listen.
    • scheme

      public String scheme()
      Description copied from interface: Transport
      Returns the transport scheme, e.g. tcp, ws, mem.
    • capabilities

      public Set<Transport.Capability> capabilities()
      Description copied from interface: Transport
      Reports what this binding provides. The default is the reliable, ordered, unencrypted, non-attesting posture every binding has at least; bindings that encrypt or attest override it.
      Returns:
      the capabilities, never empty
    • listen

      public AutoCloseable listen(String bindAddress, Consumer<TransportConnection> onAccept) throws IOException
      Description copied from interface: Transport
      Starts listening for inbound connections.
      Parameters:
      bindAddress - a transport-specific bind address
      onAccept - invoked for each accepted connection
      Returns:
      a handle that stops listening when closed
      Throws:
      IOException - if the address cannot be bound
    • boundPort

      public int boundPort(String bindAddress)
      The port a listener bound, for a bind address with port 0 (tests).
    • dial

      public TransportConnection dial(String address) throws IOException
      Description copied from interface: Transport
      Opens a connection to a peer address.
      Parameters:
      address - a transport-specific address
      Returns:
      the open connection
      Throws:
      IOException - if the peer cannot be reached
    • options

      public final HttpOptions options()
      The binding's options.
    • counters

      public final HttpCounters counters()
      The binding's counters (JS-H-12).
    • close

      public void close()
      Closes every listener and connection this binding opened; idempotent.
      Specified by:
      close in interface AutoCloseable