vendredi 25 mars 2016

Cannot CreateAnswer Web RTC

I'm trying in web rtc. When I send/received data from Signaling Server, I got this error: CreateAnswer failed because remote_description is not an offer.

This is my code:

...
unction gotMessageFromServer(event) {
    if (!pc) {
        start(false);
    }

    var signal = JSON.parse(event.data);
    if(signal.sdp) {
        count++;
        // console.log(count);
        console.log(signal);
        pc.setRemoteDescription(new RTCSessionDescription(signal.sdp), function() {
            pc.createAnswer(gotDescription, createAnswerError);
        });
    } else if(signal.ice) {
        pc.addIceCandidate(new RTCIceCandidate(signal.ice));
    }
}
...
function gotDescription(description) {
    trace('got desctiption');
    pc.setLocalDescription(description, function() {
            serverConnection.send(JSON.stringify({'sdp': description}));
            trace('send sdp description to server')
        },
        function() {
            trace('set description error');
        });
}

Could anyone please help me to figure out what's my fault. Thank you very much




Aucun commentaire:

Enregistrer un commentaire