diff --git a/sfu/forwarding.go b/sfu/forwarding.go index aaa7a70..f1e985b 100644 --- a/sfu/forwarding.go +++ b/sfu/forwarding.go @@ -92,6 +92,13 @@ func BindPeerLifecycle(roomID, peerID string, pc *webrtc.PeerConnection) { timer *time.Timer ) + room, exists := GetRoom(roomID) + if !exists { + logger.LogWarnMessage("BindPeerLifecycle: tried to bind non existing room " + roomID) + return + } + server := room.Server + startTimer := func() { mu.Lock() defer mu.Unlock() @@ -109,7 +116,7 @@ func BindPeerLifecycle(roomID, peerID string, pc *webrtc.PeerConnection) { } _ = LeaveRoom(roomID, peerID) if OnPeerDisconnected != nil { - OnPeerDisconnected(roomID, peerID) + OnPeerDisconnected(roomID, peerID, server) } }) } @@ -134,7 +141,7 @@ func BindPeerLifecycle(roomID, peerID string, pc *webrtc.PeerConnection) { cancelTimer() _ = LeaveRoom(roomID, peerID) if OnPeerDisconnected != nil { - OnPeerDisconnected(roomID, peerID) + OnPeerDisconnected(roomID, peerID, server) } } }) @@ -149,7 +156,7 @@ func BindPeerLifecycle(roomID, peerID string, pc *webrtc.PeerConnection) { cancelTimer() _ = LeaveRoom(roomID, peerID) if OnPeerDisconnected != nil { - OnPeerDisconnected(roomID, peerID) + OnPeerDisconnected(roomID, peerID, server) } } })