Skip to content

Commit

Permalink
Merge pull request #688 from mozilla/feature/broadcast-host-changes
Browse files Browse the repository at this point in the history
Broadcast host_changed events when hub.host changes
  • Loading branch information
johnshaughnessy authored Mar 2, 2023
2 parents 25c4c24 + 37a01f1 commit dc5838d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ret/hub.ex
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,12 @@ defmodule Ret.Hub do

if host && host != hub.host do
hub |> changeset_for_new_host(host) |> Repo.update!()

RetWeb.Endpoint.broadcast("hub:" <> hub.hub_sid, "host_changed", %{
host: host,
port: Hub.janus_port(),
turn: Hub.generate_turn_info()
})
else
hub
end
Expand Down
5 changes: 5 additions & 0 deletions lib/ret_web/channels/hub_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,11 @@ defmodule RetWeb.HubChannel do
{:noreply, socket}
end

def handle_out("host_changed" = event, payload, socket) do
push(socket, event, payload)
{:noreply, socket}
end

defp maybe_push_naf(
socket,
event,
Expand Down

0 comments on commit dc5838d

Please sign in to comment.