pub struct RealtimeClient { /* private fields */ }Expand description
Client for Supabase Realtime WebSocket connections.
Wraps Arc<Inner> — cheaply cloneable, Send + Sync.
Implementations§
Source§impl RealtimeClient
impl RealtimeClient
Sourcepub fn new(
url: impl Into<String>,
api_key: impl Into<String>,
) -> Result<Self, RealtimeError>
pub fn new( url: impl Into<String>, api_key: impl Into<String>, ) -> Result<Self, RealtimeError>
Create a new RealtimeClient from a Supabase URL and API key.
Sourcepub fn with_config(config: RealtimeConfig) -> Result<Self, RealtimeError>
pub fn with_config(config: RealtimeConfig) -> Result<Self, RealtimeError>
Create a new RealtimeClient with full configuration.
Sourcepub async fn connect(&self) -> Result<(), RealtimeError>
pub async fn connect(&self) -> Result<(), RealtimeError>
Connect to the Supabase Realtime server via WebSocket.
Establishes the WebSocket connection and starts background reader, heartbeat, and auto-reconnect tasks.
Sourcepub async fn disconnect(&self) -> Result<(), RealtimeError>
pub async fn disconnect(&self) -> Result<(), RealtimeError>
Disconnect from the Realtime server.
Sourcepub fn channel(&self, name: &str) -> ChannelBuilder
pub fn channel(&self, name: &str) -> ChannelBuilder
Create a ChannelBuilder for the given name.
The topic will be "realtime:<name>".
Sourcepub async fn remove_channel(
&self,
channel: &RealtimeChannel,
) -> Result<(), RealtimeError>
pub async fn remove_channel( &self, channel: &RealtimeChannel, ) -> Result<(), RealtimeError>
Remove a channel (unsubscribe and forget).
Sourcepub async fn remove_all_channels(&self) -> Result<(), RealtimeError>
pub async fn remove_all_channels(&self) -> Result<(), RealtimeError>
Remove all channels.
Sourcepub fn channels(&self) -> Vec<RealtimeChannel>
pub fn channels(&self) -> Vec<RealtimeChannel>
Get a list of all active channels.
Sourcepub async fn set_auth(&self, token: &str) -> Result<(), RealtimeError>
pub async fn set_auth(&self, token: &str) -> Result<(), RealtimeError>
Update the auth token for the realtime connection.
If connected, pushes the new access token to the server for each subscribed channel.
Mirrors supabase.realtime.setAuth(token).
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if the client is currently connected.
Trait Implementations§
Source§impl Clone for RealtimeClient
impl Clone for RealtimeClient
Source§fn clone(&self) -> RealtimeClient
fn clone(&self) -> RealtimeClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more