fix
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 1m35s

This commit is contained in:
Smile Rex
2026-01-26 19:54:25 +03:00
parent 06a6b70467
commit b013285408
3 changed files with 32 additions and 14 deletions

11
peer.go
View File

@@ -63,13 +63,8 @@ func NewPeer(conn *websocket.Conn, room *Room) *Peer {
pc.OnTrack(func(remote *webrtc.TrackRemote, _ *webrtc.RTPReceiver) {
local := NewTrack(remote)
p.Room.mu.Lock()
for _, other := range p.Room.peers {
if other.ID != p.ID {
other.AddTrack(local)
}
}
p.Room.mu.Unlock()
// 🔥 регистрируем трек в комнате
p.Room.AddTrack(p, local)
for {
pkt, _, err := remote.ReadRTP()
@@ -95,7 +90,7 @@ func (p *Peer) AddTrack(track *Track) {
func (p *Peer) ReadLoop() {
defer func() {
p.Conn.Close()
p.Room.Remove(p.ID)
p.Room.RemovePeer(p.ID)
p.PC.Close()
}()