Swift: Broadcast a message

Broadcast a message to all connected clients to a channel.

Examples

Send a message via websocket

supabase.realtime
  .channel("room1")
  .subscribe \{ status, error in
    if status == .subscribed \{
      Task \{
        await channel.send(
          type: "broadcast",
          event: "cursor-pos",
          payload: ["x": Double.random(in: 0...1), "y": Double.random(in: 0...1)]
        )
      \}
    \}
  \}

Send a message via REST

await supabase.realtime
  .channel("room1")
  .send(
    type: "broadcast",
    event: "cursor-pos",
    payload: ["x": Double.random(in: 0...1), "y": Double.random(in: 0...1)]
  )