Исправлена гонка записи в сокет

This commit is contained in:
set
2026-03-14 21:16:47 +02:00
parent 56a85a436b
commit ef591072f3
4 changed files with 108 additions and 21 deletions

View File

@@ -9,7 +9,6 @@ import (
"net/http"
"os"
"github.com/gorilla/websocket"
"github.com/joho/godotenv"
"github.com/pion/webrtc/v4"
)
@@ -51,7 +50,7 @@ func OnLocalICECandidate(roomID string, peerID string, candidate webrtc.ICECandi
buffer.PutUint32(uint32(len([]byte(jsonCandidate))))
buffer.PutBytes([]byte(jsonCandidate))
buffer.Flip()
room.Server.Socket.WriteMessage(websocket.BinaryMessage, buffer.Bytes())
room.Server.WriteBinary(buffer.Bytes())
}
// Обработка нового оффера от сервера для конкретного пира (при renegotiation)
@@ -73,5 +72,5 @@ func OnServerOffer(roomID string, peerID string, offer webrtc.SessionDescription
buffer.PutUint32(uint32(len([]byte(jsonOffer))))
buffer.PutBytes([]byte(jsonOffer))
buffer.Flip()
room.Server.Socket.WriteMessage(websocket.BinaryMessage, buffer.Bytes())
room.Server.WriteBinary(buffer.Bytes())
}