ExUtcp.Transports.WebRTC.Connection (ex_utcp v0.3.2)

Copy Markdown View Source

WebRTC peer connection management for UTCP.

Handles:

  • Peer connection establishment with signaling
  • ICE candidate exchange and NAT traversal
  • Data channel creation and management
  • Tool call communication over data channels

Summary

Functions

Calls a tool over the WebRTC data channel.

Calls a tool stream over the WebRTC data channel.

Returns a specification to start this module under a supervisor.

Closes the WebRTC connection.

Gets the connection state.

Gets the ICE connection state.

Starts a new WebRTC connection.

Types

t()

@type t() :: %ExUtcp.Transports.WebRTC.Connection{
  call_id_counter: integer(),
  connection_state: atom(),
  data_channel: pid() | nil,
  ice_connection_state: atom(),
  ice_servers: [map()],
  peer_connection: pid() | nil,
  pending_calls: %{required(String.t()) => pid()},
  provider: map(),
  signaling_pid: pid() | nil,
  signaling_server: String.t()
}

Functions

call_tool(pid, tool_name, args, timeout \\ 30000)

@spec call_tool(pid(), String.t(), map(), integer()) ::
  {:ok, map()} | {:error, term()}

Calls a tool over the WebRTC data channel.

call_tool_stream(pid, tool_name, args, timeout \\ 30000)

@spec call_tool_stream(pid(), String.t(), map(), integer()) ::
  {:ok, Enumerable.t()} | {:error, term()}

Calls a tool stream over the WebRTC data channel.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(pid)

@spec close(pid()) :: :ok

Closes the WebRTC connection.

get_connection_state(pid)

@spec get_connection_state(pid()) :: atom()

Gets the connection state.

get_ice_connection_state(pid)

@spec get_ice_connection_state(pid()) :: atom()

Gets the ICE connection state.

start_link(provider, signaling_server, ice_servers)

@spec start_link(map(), String.t(), [map()]) :: {:ok, pid()} | {:error, term()}

Starts a new WebRTC connection.