Amarula.Protocol.Socket.WebSocketClient (amarula v0.1.0)

View Source

WebSocket client implementation using websockex.

This module provides a WebSocket client that handles connection management, message sending/receiving, and event emission for WhatsApp WebSocket communication.

Summary

Functions

Closes the WebSocket connection.

Checks if the WebSocket is closed.

Checks if the WebSocket is closing.

Connects to the WebSocket server.

Checks if the WebSocket is connecting.

Checks if the WebSocket is open.

Sends data through the WebSocket connection.

Starts a new WebSocket client.

Types

t()

@type t() :: %Amarula.Protocol.Socket.WebSocketClient{
  connect_timeout_timer: reference() | nil,
  connection_state: Amarula.Protocol.Socket.Types.connection_state(),
  keep_alive_interval_ms: non_neg_integer(),
  keep_alive_timer: reference() | nil,
  parent_pid: pid(),
  url: String.t()
}

Functions

close(pid \\ __MODULE__)

Closes the WebSocket connection.

closed?(pid \\ __MODULE__)

Checks if the WebSocket is closed.

closing?(pid \\ __MODULE__)

Checks if the WebSocket is closing.

connect(pid \\ __MODULE__)

Connects to the WebSocket server.

connecting?(pid \\ __MODULE__)

Checks if the WebSocket is connecting.

init(state)

open?(pid \\ __MODULE__)

Checks if the WebSocket is open.

send_data(pid \\ __MODULE__, data)

Sends data through the WebSocket connection.

start_link(opts \\ [])

Starts a new WebSocket client.

Options

  • :parent_pid - Required. PID of the Connection that will receive events.
  • :url - WebSocket URL (defaults to WhatsApp WebSocket URL)
  • :headers - List or map of HTTP headers
  • Other options for timeouts and configuration