2016-08-17 6 views
1

WebRTCを学習しようとしています。私はいくつかのコードをコピーして、私はこのエラーを取得:'RTCDataChannel'で 'send'を実行できませんでした:RTCDataChannel.readyStateは開かれていません

は「RTCDataChannel」on「に送る」を実行に失敗しました:RTCDataChannel.readyStateは、いずれかが助けることができる

「オープン」ではないのですか?

コードスコア:http://www.tutorialspoint.com/webrtc/webrtc_text_demo.htm

+0

を??? –

+0

'npm install'であなたのアプリに必要なライブラリをすべてインストールしましたか? –

+0

私はこれが助けてくれると信じています:http://stackoverflow.com/questions/22470291/rtcdatachannels-readystate-is-not-open –

答えて

5

{optional: [{RtpDataChannels: true}]}を除去した後ondatachannel取り扱い追加:どのようにあなたのアプリケーションを実行している

myConnection.onicecandidate = function (event) { 

    if (event.candidate) { 
     send({ 
      type: "candidate", 
      candidate: event.candidate 
     }); 
    } 
    }; 

    myConnection.ondatachannel = function(event) { 
    var receiveChannel = event.channel; 
    receiveChannel.onmessage = function(event) { 
     console.log("ondatachannel message:", event.data); 
    }; 
    }; 

    openDataChannel(); 
関連する問題