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 authored Mar 8, 2024
1 parent 16996d3 commit 95e0bfa
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 @@ -435,7 +435,16 @@ defmodule Jellyfish.Room do
:ok = Engine.remove_endpoint(state.engine_pid, peer_id)
Event.broadcast_server_notification({:peer_disconnected, state.id, peer_id})
:telemetry.execute([:jellyfish, :room], %{peer_disconnects: 1}, %{room_id: state.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 95e0bfa

Please sign in to comment.