Class SupabaseRealtime
java.lang.Object
com.codename1.cloud.supabase.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 Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceReceives database changes.static final classA Realtime channel: a set of change listeners joined together. -
Method Summary
Modifier and TypeMethodDescriptionCreates a channel.voidCloses the socket and drops every channel.static booleanTrue when this port has a WebSocket client.
-
Method Details
-
isSupported
public static boolean isSupported()True when this port has a WebSocket client.
Returns
whether realtime works here
-
channel
Creates a channel. Add listeners, then call
subscribe().Parameters
name: the channel name
Returns
the channel
-
disconnect
public void disconnect()Closes the socket and drops every channel.
-