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

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.

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.

init(state)

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