SDP Answer согласно протоколу g365sfu

This commit is contained in:
set
2026-03-14 19:42:16 +02:00
parent 4c2d382b34
commit 9112764d6a

View File

@@ -137,11 +137,24 @@ func processData(data <-chan []byte, connection *connection.Connection) {
logger.LogWarnMessage("failed to unmarshal offer from peer " + peerID + " in room " + roomID + ": " + err.Error())
continue
}
_, err = sfu.JoinWithOffer(roomID, peerID, offer)
answer, err := sfu.JoinWithOffer(roomID, peerID, offer)
if err != nil {
logger.LogWarnMessage("failed to join peer " + peerID + " to room " + roomID + ": " + err.Error())
continue
}
answerBytes, _ := json.Marshal(answer)
// Подготовка ответа для клиента с SDP answer
response := bytebuffer.Allocate(1 + 4 + len([]byte(roomID)) + 4 + len([]byte(peerID)) + 4 + len(answerBytes))
response.Put(0x05)
response.PutUint32(uint32(len([]byte(roomID))))
response.PutBytes([]byte(roomID))
response.PutUint32(uint32(len([]byte(peerID))))
response.PutBytes([]byte(peerID))
response.PutUint32(uint32(len(answerBytes)))
response.PutBytes(answerBytes)
response.Flip()
// Отправляем ответ клиенту
connection.Socket.WriteMessage(websocket.BinaryMessage, response.Bytes())
continue
}
}