1

Simple question, is it possible to make a broadcast from controller to all active channel?

For example here is my controller:

# Controller
  defmodule Rumbl.DiscussionController do
    use Rumbl.Web, :controller

    def blast(conn, _params) do
      Rumbl.Endpoint.broadcast("room:*", "push_notifications", %{message: "broadcast coooyt!!"})
      render conn, "blast.json"
    end
  end

And i have two client that still active in two channel, e.g: room:1 and room:2. Then when i call blast action, then that two client will receive some alert or push notifications. Or even better if it possible to broadcast to all channel maybe like broadcast("*:*", "push_notifications", %{}), so then all user if inside different channel e.g room and discussions will be receive push notifications.

Thanks in advance

Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
opan
  • 11
  • 1
  • 2
  • You have to broadcast to an explicit channel e.g: room:1 or room:2 `Rumbl.Endpoint.broadcast("room:1", "push_notifications", %{message: "broadcast coooyt!!"})` – TheAnh Oct 11 '16 at 10:06
  • I would either create dedicated channel "room:all" or have registry of all rooms, iterate through it and broadcast message for each room. First solution requires client to subscribe to new channel, second one doesn't. Anyway this indicates good design thinking! – BurmajaM Oct 11 '16 at 11:59
  • Hmm i guess this is not possible yet? But can user connect to multiple channel? So maybe inside one page, user connet to ```room``` and ```discussions``` channel? Thanks – opan Oct 12 '16 at 01:13

0 Answers0