WebSocket client for Sync receiver connections.
Uses WebSockex to connect from the receiver site to the sender's WebSocket endpoint. Sends requests and receives responses.
Architecture
The receiver uses this client to:
- Connect to the sender's hosted channel
- Send requests for data (tables, schema, records)
- Receive responses and notify the caller (LiveView)
Usage
{:ok, pid} = WebSocketClient.start_link(
url: "https://sender-site.com",
code: "ABC12345",
caller: self()
)
# Request available tables
WebSocketClient.request_tables(pid)
# Receive: {:sync_client, {:tables, tables}}
# Request records
WebSocketClient.request_records(pid, "users", offset: 0, limit: 100)
# Receive: {:sync_client, {:records, "users", result}}
Summary
Functions
Disconnects the WebSocket client.
Request server capabilities.
Request record count for a table.
Request records from a table with pagination.
Request schema for a specific table.
Request list of available tables from sender.
Starts the WebSocket client and connects to the sender.
Functions
@spec disconnect(pid()) :: :ok
Disconnects the WebSocket client.
@spec request_capabilities(pid()) :: :ok
Request server capabilities.
Request record count for a table.
Request records from a table with pagination.
Request schema for a specific table.
@spec request_tables(pid()) :: :ok
Request list of available tables from sender.
Starts the WebSocket client and connects to the sender.