SkyWay Web RTCを使って1:1のテキストチャットを実装しようとしています
困っていること:
メッセージの送信ができない
DataConnection.send(data)が動いていないようです
エラー内容:
Uncaught Error: Type "function Blob() { [native code] }" not yet supported
環境:(追記)
- Chrome v.63
- xamppのlocalhostドメイン
で使用
コード(該当箇所):
javascript
1// 送信元 2$('#send').click(function(){ 3 var msg = $('#msg').val(); 4 existingConnection.send(msg); 5 sendchatlog('sent msg: ' + msg); 6});
コード(全体):
JavaScript
1let peer = null; 2var existingConnection = null; 3 4peer = new Peer({ 5 key: 'a0017750-87b9-4a74-90a9-836e4b5e52b4', 6 debug: 3 7}); 8 9// openイベント 10peer.on('open', function(){ 11 $('#localId').text(peer.id); 12 sendchatlog('connected to server'); 13}); 14 15// 接続元 16$('#connect').click(function(){ 17 existingConnection = peer.connect($('#remoteId').val()); 18 sendchatlog('sent connection'); 19 messaging(); 20}) 21 22// 接続先 23peer.on('connection', function(connection){ 24 existingConnection = connection; 25 sendchatlog('received connection'); 26 messaging(); 27}) 28 29function sendchatlog(msg){ 30 $('#chatLog').append('<p>>' + msg + '</p>'); 31} 32 33function messaging(){ 34 sendchatlog(existingConnection.label); 35 36 // 送信元 37 $('#send').click(function(){ 38 var msg = $('#msg').val(); 39 existingConnection.send(msg); 40 sendchatlog('sent msg: ' + msg); 41 }); 42 43 // 送信先 44 existingConnection.on('data', function(data){ 45 sendchatlog('received msg: ' + data); 46 }) 47}
動かしてみましたが、特にエラーなどは発生しませんでした。
使用しているブラウザやHTML部分も追記したほうが、回答が得られやすくなるかと思います。
あなたの回答
tips
プレビュー