[B4X] Supabase - The Open Source Firebase alternative
Supabase is an open source Firebase alternative. It provides all the backend services you need to build a product. Supabase uses Postgres database with real-time capabilities. Basically, supabase provides an interface to manage postgres database that you can use to create table and insert, edit...
www.b4x.com
Send and receive messages using Realtime Broadcast
Setup
[B4X] Supabase - Realtime
https://www.b4x.com/android/forum/threads/b4x-supabase-the-open-source-firebase-alternative.149855/ This is a very simple tutorial on how to use the Realtime module. A more detailed tutorial is coming soon. Step 1 Click in your project on "Project -> Build configurations -> Conditional...
www.b4x.com
Listening to Broadcast messages
B4X:
Realtime _
.Channel("Room1","","") _
.On(Realtime.SubscribeType_Broadcast) _
.ReceiveOwnBroadcasts(False) _
.AcknowledgeBroadcasts(False) _
.Subscribe
B4X:
Channel1.SendBroadcast("cursor-pos",CreateMap("x":"198","y":"50"))
By default, broadcast messages are only sent to other clients. You can broadcast messages back to the sender by setting Broadcast's self parameter to true.
B4X:
Realtime _
.Channel("Room1","","") _
.On(Realtime.SubscribeType_Broadcast) _
.ReceiveOwnBroadcasts(True) _
.Subscribe
You can confirm that Realtime received your message by setting Broadcast's ack config to true.
B4X:
Realtime _
.Channel("Room1","","") _
.On(Realtime.SubscribeType_Broadcast) _
.AcknowledgeBroadcasts(True) _
.Subscribe
B4X:
Private Sub Realtime_BroadcastDataReceived(BroadcastData As SupabaseRealtime_BroadcastData)
Log("Broadcast data for event: " & BroadcastData.Event)
Log("Data:")
For Each k As String In BroadcastData.Payload.Keys
Log(k & ":" & BroadcastData.Payload.Get(k))
Next
End Sub