A2UI.Connection (A2UI v0.3.0)

Copy Markdown View Source

Opaque handle representing a connected client.

A connection is created by a transport when a client connects to an agent. The agent receives the connection in its handle_connect/2 callback and passes it to A2UI.Agent.send_message/2 to deliver messages back.

Fields

  • :id — unique connection identifier (string)
  • :transport — module implementing A2UI.Transport (used for message delivery)
  • :ref — transport-specific reference passed to deliver_message/2
  • :pid — process to monitor for disconnect detection

Summary

Functions

Creates a local connection for the calling process.

Types

t()

@type t() :: %A2UI.Connection{
  id: String.t(),
  pid: pid(),
  ref: term(),
  transport: module()
}

Functions

local(pid \\ self())

@spec local(pid()) :: t()

Creates a local connection for the calling process.

Convenience for tests and local transports. Sets the transport to A2UI.Transport.Local and uses the given pid as both :ref and :pid.