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

Copy Markdown View Source

WebSocket connection handler for UTCP transport.

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

Summary

Functions

Calls a tool through the WebSocket connection.

Calls a tool stream through the WebSocket connection.

Clears the message queue.

Closes the WebSocket connection.

Gets all messages from the message queue.

Gets the last used timestamp.

Gets the next message from the message queue.

Sends a message through the WebSocket connection.

Starts a new WebSocket connection.

Updates the last used timestamp.

Functions

call_tool(pid, tool_name, args, opts \\ [])

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

Calls a tool through the WebSocket connection.

call_tool_stream(pid, tool_name, args, opts \\ [])

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

Calls a tool stream through the WebSocket connection.

clear_messages(pid)

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

Clears the message queue.

close(pid)

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

Closes the WebSocket connection.

get_all_messages(pid)

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

Gets all messages from the message queue.

get_last_used(pid)

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

Gets the last used timestamp.

get_next_message(pid, timeout \\ 5000)

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

Gets the next message from the message queue.

handle_call(msg, from, state)

send_message(pid, message)

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

Sends a message through the WebSocket connection.

start_link(provider)

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

Starts a new WebSocket connection.

start_link(url, provider, opts \\ [])

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

update_last_used(pid)

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

Updates the last used timestamp.