SDP Answer согласно протоколу g365sfu
This commit is contained in:
@@ -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())
|
logger.LogWarnMessage("failed to unmarshal offer from peer " + peerID + " in room " + roomID + ": " + err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, err = sfu.JoinWithOffer(roomID, peerID, offer)
|
answer, err := sfu.JoinWithOffer(roomID, peerID, offer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogWarnMessage("failed to join peer " + peerID + " to room " + roomID + ": " + err.Error())
|
logger.LogWarnMessage("failed to join peer " + peerID + " to room " + roomID + ": " + err.Error())
|
||||||
continue
|
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
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user