C# Reference v1.0

Subscribe to channel

Subscribe to realtime changes in your database.

  • Realtime is disabled by default for new Projects for better database performance and security. You can turn it on by managing replication.
  • If you want to receive the "previous" data for updates and deletes, you will need to set 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 });