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

WebSocket connection handler for UTCP transport.

This module handles individual WebSocket connections and implements
the WebSockex behavior for managing WebSocket state and messages.

# `call_tool`

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

Calls a tool through the WebSocket connection.

# `call_tool_stream`

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

Calls a tool stream through the WebSocket connection.

# `clear_messages`

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

Clears the message queue.

# `close`

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

Closes the WebSocket connection.

# `get_all_messages`

```elixir
@spec get_all_messages(pid()) :: [String.t()]
```

Gets all messages from the message queue.

# `get_last_used`

```elixir
@spec get_last_used(pid()) :: integer()
```

Gets the last used timestamp.

# `get_next_message`

```elixir
@spec get_next_message(pid(), timeout()) :: {:ok, String.t()} | {:error, :timeout}
```

Gets the next message from the message queue.

# `handle_call`

# `send_message`

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

Sends a message through the WebSocket connection.

# `start_link`

```elixir
@spec start_link(%{url: binary()}) :: {:ok, pid()} | {:error, term()}
```

Starts a new WebSocket connection.

# `start_link`

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

# `update_last_used`

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

Updates the last used timestamp.

---

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