B4J Question [B4X] Websocket - Broadcast and Presence

Alexander Stolte

Expert
Licensed User
Longtime User
I am trying to add the realtime broadcast and presence function to the Supabase lib., but so far without success. Maybe I understand the documentation wrong?


The following is the subscribe documentation for the postgres changes, broadcast and presence.
B4X:
{
   "event": "phx_join",
   "topic": string,
   "payload": {
      "config": {
         "broadcast": {
            "self": boolean
         },
         "presence": {
            "key": string
         },
         "postgres_changes": [
            {
               "event": "*" | "INSERT" | "UPDATE" | "DELETE",
               "schema": string,
               "table": string,
               "filter": string + '=' + "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "in" +  '.' + string
            }
         ]
      }
   },
   "ref": string
}
This is how I understand the documentation: If I want to subscribe to postgres changes, then I only need the postgres_changes part. But if I only want broadcast, then only the broadcast part and the same for presence

Unfortunately this does not work, it always wants to subscribe for postgres_changes, although I only have the broadcast part in the json string.
I am grateful for any help that improves my understanding.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…