# `ExUtcp.Transports.WebRTC.Connection`
[🔗](https://github.com/universal-tool-calling-protocol/elixir-utcp/blob/main/lib/ex_utcp/transports/webrtc/connection.ex#L1)

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

# `t`

```elixir
@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()) =&gt; pid()},
  provider: map(),
  signaling_pid: pid() | nil,
  signaling_server: String.t()
}
```

# `call_tool`

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

Calls a tool over the WebRTC data channel.

# `call_tool_stream`

```elixir
@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`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

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

Closes the WebRTC connection.

# `get_connection_state`

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

Gets the connection state.

# `get_ice_connection_state`

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

Gets the ICE connection state.

# `start_link`

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

Starts a new WebRTC connection.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
