Supabase.Realtime.HTTP
(supabase_realtime v0.5.0)
Copy Markdown
HTTP fallback for Supabase Realtime broadcasts.
Sends broadcast messages through the Supabase REST API when the WebSocket connection is not available.
When Does the Fallback Trigger?
All three conditions must be true:
- The WebSocket connection status is not
:open. - The
:http_fallbackoption is set totrueon the connection. - The message being sent is a broadcast message.
Other message types (presence, postgres_changes) are never sent over HTTP. They go into the send buffer and wait for the WebSocket to reconnect.
Example
# Usually called by the Connection module, but can be used directly:
Supabase.Realtime.HTTP.broadcast(client, token, "realtime:room:lobby", "new_msg", %{body: "hi"})
Summary
Functions
Sends a broadcast message via HTTP POST using the Supabase Fetcher.
Functions
@spec broadcast(Supabase.Client.t(), String.t(), String.t(), String.t(), map()) :: :ok | {:error, term()}
Sends a broadcast message via HTTP POST using the Supabase Fetcher.
Parameters
client- TheSupabase.Clientstructtoken- The access token for authorizationtopic- The channel topicevent- The broadcast event namepayload- The message payload