ExUtcp.Transports.WebRTC.ConnectionBehaviour behaviour (ex_utcp v0.3.2)

Copy Markdown View Source

Behaviour for WebRTC Connection modules.

This allows for mocking in tests.

Summary

Callbacks

Calls a tool over the WebRTC data channel.

Calls a tool stream over the WebRTC data channel.

Closes the WebRTC connection.

Gets the connection state.

Gets the ICE connection state.

Starts a new WebRTC connection.

Callbacks

call_tool(pid, tool_name, args, timeout)

@callback call_tool(
  pid :: pid(),
  tool_name :: String.t(),
  args :: map(),
  timeout :: integer()
) :: {:ok, map()} | {:error, term()}

Calls a tool over the WebRTC data channel.

call_tool_stream(pid, tool_name, args, timeout)

@callback call_tool_stream(
  pid :: pid(),
  tool_name :: String.t(),
  args :: map(),
  timeout :: integer()
) :: {:ok, Enumerable.t()} | {:error, term()}

Calls a tool stream over the WebRTC data channel.

close(pid)

@callback close(pid :: pid()) :: :ok

Closes the WebRTC connection.

get_connection_state(pid)

@callback get_connection_state(pid :: pid()) :: atom()

Gets the connection state.

get_ice_connection_state(pid)

@callback get_ice_connection_state(pid :: pid()) :: atom()

Gets the ICE connection state.

start_link(provider, signaling_server, ice_servers)

@callback start_link(
  provider :: map(),
  signaling_server :: String.t(),
  ice_servers :: [map()]
) ::
  {:ok, pid()} | {:error, term()}

Starts a new WebRTC connection.