mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
docs: Add Kotlin broadcasting via REST and Realtime authorization docs (#33234)
* Add broadcasting via REST * add realtime authorization docs
This commit is contained in:
1 parent
7a940d2a5d
commit
95594570b0
2 files changed
+48
-3
No files matched your search
@@ -183,6 +183,19 @@ Then, to join a topic with RLS enabled, instantiate the Channel with the `privat
|
||||
print("Connected!")
|
||||
```
|
||||
|
||||
</TabPanel>
|
||||
<TabPanel id="kotlin" label="Kotlin">
|
||||
```kotlin
|
||||
val channel = supabase.channel("room-1") {
|
||||
isPrivate = true
|
||||
}
|
||||
channel.broadcastFlow<MyPayload>(event = "test").onEach {
|
||||
println(it)
|
||||
}.launchIn(scope) // launch in your coroutine scope
|
||||
channel.subscribe(blockUntilSubscribed = true)
|
||||
println("Connected!")
|
||||
```
|
||||
|
||||
</TabPanel>
|
||||
<TabPanel id="python" label="Python">
|
||||
```py
|
||||
|
||||
@@ -4643,8 +4643,6 @@ functions:
|
||||
}.launchIn(coroutineScope) // launch a new coroutine to collect the flow
|
||||
|
||||
channel.subscribe(blockUntilSubscribed = true)
|
||||
|
||||
channel.broadcast(event = "message", Message("I joined!", "John"))
|
||||
```
|
||||
- id: listen-to-presence-updates
|
||||
name: Listen to presence updates
|
||||
@@ -4830,7 +4828,41 @@ functions:
|
||||
You have two methods you can use if you want to listen for updates on a specific database row:
|
||||
- `postgresSingleDataFlow` fetches the initial data matching the filter and then emits updates based on realtime events.
|
||||
- `postgresChangeFlow` emits the raw data received by realtime. To filter the realtime queries, use the `filter` method.
|
||||
|
||||
- id: broadcast-message
|
||||
title: broadcastMessage()
|
||||
description: |
|
||||
Broadcast a message to all connected clients to a channel.
|
||||
notes: |
|
||||
- When using REST you don't need to subscribe to the channel
|
||||
$ref: '@supabase/realtime-js.RealtimeChannel.send'
|
||||
examples:
|
||||
- id: send-a-message
|
||||
name: Send a message via websocket
|
||||
isSpotlight: true
|
||||
code: |
|
||||
```kotlin
|
||||
val channel = supabase.channel("room1")
|
||||
channel.subscribe(blockUntilSubscribed = true)
|
||||
channel.broadcast("cursor-pos", message = buildJsonObject {
|
||||
put("x", 10)
|
||||
put("y", 20)
|
||||
})
|
||||
```
|
||||
response: |
|
||||
```
|
||||
ok | timed out | error
|
||||
```
|
||||
- id: send-a-message-via-rest
|
||||
name: Send a message via REST
|
||||
isSpotlight: true
|
||||
code: |
|
||||
```kotlin
|
||||
val channel = supabase.channel("room1")
|
||||
channel.broadcast("cursor-pos", message = buildJsonObject {
|
||||
put("x", 10)
|
||||
put("y", 20)
|
||||
})
|
||||
```
|
||||
- id: remove-channel
|
||||
description: |
|
||||
Unsubscribes and removes Realtime channel from Realtime client.
|
||||
|
||||
Reference in new issue
Block a user