1 year ago
#304298
mohammedshetaya
RTCPeerConnection.CreateAnswer() fails
I am trying to set up the signaling between a browser client and unity client. the two clients use Webrtc and I am using a websocket to make the signaling happen. First, I am creating an offer on the click of a button in the browser. the offer reaches the c# client and the localConnection.setRemoteDescription works fine, then I need to create an answer. Instead the answer is an empty object recieved
{"type":0,"sdp":null}
Any Ideas if there is something wrong?
public void handleIncommingMessages(object sender, MessageEventArgs e) {
SignalingMessage message = JsonConvert.DeserializeObject<SignalingMessage>(e.Data);
switch (message.type){
case "offer": handleOffer(message); break;
case "answer": handleAnswer(message);break;
case "ice-candidate": handleIceCandidateMessage(message);break;
}
}
void handleOffer(SignalingMessage offerMessage)
{
localConnection.SetRemoteDescription(ref offerMessage.sessionDescription);
RTCSessionDescriptionAsyncOperation answer = localConnection.CreateAnswer();
Debug.Log(answer.Desc.sdp);
SignalingMessage answerMessage = new SignalingMessage {type = "answer" , sessionDescription = answer.Desc , iceCandidate = null};
socket.Send(JsonConvert.SerializeObject(answerMessage));
}
this is the implementation of the SignalingMessage class which represents any message to be sent over the websocket
public class SignalingMessage
{
public string type;
public RTCSessionDescription sessionDescription;
public RTCIceCandidate iceCandidate;
}
c#
unity-game-engine
webrtc
peer
rtcpeerconnection
0 Answers
Your Answer