Subscribe to realtime changes in your database.
REPLICA IDENTITY
to FULL
, like this: ALTER TABLE your_table REPLICA IDENTITY FULL;
class CursorBroadcast : BaseBroadcast
\{
[JsonProperty("cursorX")]
public int CursorX \{get; set;\}
[JsonProperty("cursorY")]
public int CursorY \{get; set;\}
\}
var channel = supabase.Realtime.Channel("any");
var broadcast = channel.Register<CursorBroadcast>();
broadcast.AddBroadcastEventHandler((sender, baseBroadcast) =>
\{
var response = broadcast.Current();
\});
await channel.Subscribe();
// Send a broadcast
await broadcast.Send("cursor", new CursorBroadcast \{ CursorX = 123, CursorY = 456 \});
class UserPresence : BasePresence
\{
[JsonProperty("cursorX")]
public bool IsTyping \{get; set;\}
[JsonProperty("onlineAt")]
public DateTime OnlineAt \{get; set;\}
\}
var channel = supabase.Realtime.Channel("any");
var presenceKey = Guid.NewGuid().ToString();
var presence = channel.Register<UserPresence>(presenceKey);
presence.AddPresenceEventHandler(EventType.Sync, (sender, type) =>
\{
Debug.WriteLine($"The Event Type: \{type\}");
var state = presence.CurrentState;
\});
await channel.Subscribe();
// Send a presence update
await presence.Track(new UserPresence \{ IsTyping = false, OnlineAt = DateTime.Now \});
await supabase.From<City>().On(ListenType.All, (sender, change) =>
\{
Debug.WriteLine(change.Payload.Data);
\});
var channel = supabase.Realtime.Channel("realtime", "public", "*");
channel.AddPostgresChangeHandler(ListenType.All, (sender, change) =>
\{
// The event type
Debug.WriteLine(change.Event);
// The changed record
Debug.WriteLine(change.Payload);
\});
await channel.Subscribe();
await supabase.From<City>().On(ListenType.Inserts, (sender, change) =>
\{
Debug.WriteLine(change.Payload.Data);
\});
await supabase.From<City>().On(ListenType.Updates, (sender, change) =>
\{
Debug.WriteLine(change.Payload.Data);
\});
await supabase.From<City>().On(ListenType.Deletes, (sender, change) =>
\{
Debug.WriteLine(change.Payload.Data);
\});
var channel = supabase.Realtime.Channel("realtime", "public", "countries", "id", "id=eq.200");
channel.AddPostgresChangeHandler(ListenType.All, (sender, change) =>
\{
// The event type
Debug.WriteLine(change.Event);
// The changed record
Debug.WriteLine(change.Payload);
\});
await channel.Subscribe();