Skip to content

Commit

Permalink
[RTC-498] Fix tracks present after peer disconnect (#164)
Browse files Browse the repository at this point in the history
* Refactor server_notification_test.exs

* Refactor v2

* Remove tracks when peer disconnects

* Remove comment

* Revert unnecessary change
  • Loading branch information
roznawsk committed Mar 8, 2024
1 parent 0eb6625 commit dcc6a46
Show file tree
Hide file tree
Showing 2 changed files with 223 additions and 137 deletions.
11 changes: 10 additions & 1 deletion lib/jellyfish/room.ex
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,16 @@ defmodule Jellyfish.Room do
{peer_id, peer} ->
:ok = Engine.remove_endpoint(state.engine_pid, peer_id)
Event.broadcast_server_notification({:peer_disconnected, state.id, peer_id})
peer = %{peer | status: :disconnected, socket_pid: nil}

peer.tracks
|> Map.values()
|> Enum.each(
&Event.broadcast_server_notification(
{:track_removed, state.id, {:peer_id, peer_id}, &1}
)
)

peer = %{peer | status: :disconnected, socket_pid: nil, tracks: %{}}

put_in(state, [:peers, peer_id], peer)
|> maybe_schedule_peerless_purge()
Expand Down
Loading

0 comments on commit dcc6a46

Please sign in to comment.