Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class SupabaseRealtime

  1. Object
  2. SupabaseRealtime

Supabase Realtime over com.codename1.io.WebSocket: Phoenix channels with database change events (postgres_changes).

One socket serves every channel. It joins channels, sends a heartbeat every 25 seconds and rejoins after a reconnect. Reconnects back off exponentially, with jitter, up to a minute apart. When the signed-in session changes, the new access token is pushed to every joined channel. Listeners are called on the EDT. On a port without WebSocket support, isSupported() is false and subscribe() does nothing.

Supabase supabase = new Supabase("https://xyzcompany.supabase.co", "public-anon-key");
supabase.realtime().channel("room1")
        .onPostgresChanges("INSERT", "public", "messages", null, new SupabaseRealtime.ChangeListener() {
            public void onChange(String type, Map<String, Object> record, Map<String, Object> oldRecord) {
                Log.p("New message " + record.get("text"));
            }
        })
        .subscribe();

Nested types

interface SupabaseRealtime.ChangeListenerReceives database changes.
class SupabaseRealtime.ChannelA Realtime channel: a set of change listeners joined together.

Methods

public static boolean isSupported()True when this port has a WebSocket client.
public SupabaseRealtime.Channel channel(String name)Creates a channel.
public void disconnect()Closes the socket and drops every channel.

Inherited methods

Method details

isSupported

public static boolean isSupported()
True when this port has a WebSocket client.

Returns

whether realtime works here

channel

public SupabaseRealtime.Channel channel(String name)
Creates a channel. Add listeners, then call subscribe().

Parameters

name String
the channel name

Returns

the channel

disconnect

public void disconnect()
Closes the socket and drops every channel.