Исправление Race при renegotiation

This commit is contained in:
set
2026-03-17 19:17:02 +02:00
parent 96df1e52f9
commit 6dadec6b64
6 changed files with 109 additions and 78 deletions

View File

@@ -59,7 +59,7 @@ func Bootstrap() {
// TURN сервер выключен в конфиге, что может влиять на соединение некоторых пользователей
logger.LogInfoMessage("starting without TURN server, peer connections may fail if clients are behind symmetric NATs")
}
logger.LogInfoMessage("server started at x.x.x.x:" + port)
logger.LogInfoMessage("server SFU started at x.x.x.x:" + port)
http.ListenAndServe(":"+port, nil)
}
@@ -116,13 +116,14 @@ func OnRoomDelete(roomID string, server *connection.Connection) {
server.WriteBinary(buffer.Bytes())
}
func OnPeerDisconnected(roomID string, peerID string, server *connection.Connection) {
buffer := bytebuffer.Allocate(1 + 4 + len([]byte(roomID)) + 4 + len([]byte(peerID)))
func OnPeerDisconnected(roomID string, peerID string, server *connection.Connection, reason sfu.DisconnectReason) {
buffer := bytebuffer.Allocate(1 + 4 + len([]byte(roomID)) + 4 + len([]byte(peerID)) + 4)
buffer.Put(byte(network.ON_PEER_DISCONNECTED))
buffer.PutUint32(uint32(len([]byte(roomID))))
buffer.PutBytes([]byte(roomID))
buffer.PutUint32(uint32(len([]byte(peerID))))
buffer.PutBytes([]byte(peerID))
buffer.PutUint32(uint32(reason))
buffer.Flip()
server.WriteBinary(buffer.Bytes())
}