Skip to content

Commit

Permalink
Added [email protected] FileBufferReader is moved to: https…
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Oct 18, 2016
1 parent 22bd197 commit ca93255
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 2,372 deletions.
6 changes: 2 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ module.exports = function(grunt) {
my_target: {
files: {
'RTCMultiConnection.min.js': ['RTCMultiConnection.js'],
'dist/rmc3.min.js': ['RTCMultiConnection.js'],
'dist/rmc3.fbr.min.js': ['dev/FileBufferReader.js'],
'dist/rmc3.min.js': ['RTCMultiConnection.js']
}
}
},
Expand All @@ -101,8 +100,7 @@ module.exports = function(grunt) {
flatten: true
},
files: {
'dist/rmc3.js': ['RTCMultiConnection.js'],
'dist/rmc3.fbr.js': ['dev/FileBufferReader.js'],
'dist/rmc3.js': ['RTCMultiConnection.js']
},
},
},
Expand Down
14 changes: 11 additions & 3 deletions RTCMultiConnection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-09-14 5:44:05 AM UTC
// Last time updated: 2016-10-18 2:19:17 PM UTC

// _____________________
// RTCMultiConnection-v3
Expand Down Expand Up @@ -1980,14 +1980,19 @@
}

if (message.readyForNextChunk) {
connection.fbr.getNextChunk(message.uuid, function(nextChunk, isLastChunk) {
connection.fbr.getNextChunk(message, function(nextChunk, isLastChunk) {
connection.peers[remoteUserId].channels.forEach(function(channel) {
channel.send(nextChunk);
});
}, remoteUserId);
return;
}

if (message.chunkMissing) {
connection.fbr.chunkMissing(message);
return;
}

connection.fbr.addChunk(message, function(promptNextChunk) {
connection.peers[remoteUserId].peer.channel.send(promptNextChunk);
});
Expand Down Expand Up @@ -2690,7 +2695,7 @@
};
}

// Last time updated: 2016-09-04 3:03:44 AM UTC
// Last time updated: 2016-10-12 6:16:40 AM UTC

// Latest file can be found here: https://cdn.webrtc-experiment.com/DetectRTC.js

Expand Down Expand Up @@ -2925,6 +2930,9 @@
var db;
try {
db = window.indexedDB.open('test');
db.onerror = function() {
return true;
};
} catch (e) {
isPrivate = true;
}
Expand Down
6 changes: 3 additions & 3 deletions RTCMultiConnection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rtcmulticonnection",
"description": "RTCMultiConnection is a WebRTC JavaScript wrapper library runs top over RTCPeerConnection API to provide multi-session establishment scenarios.",
"version": "3.3.9",
"version": "3.4.0",
"authors": [
{
"name": "Muaz Khan",
Expand Down
58 changes: 47 additions & 11 deletions demos/file-sharing.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
<head>
<title>File Sharing using RTCMultiConnection</title>

<script>
if(!location.hash.replace('#', '').length) {
location.href = location.href.split('#')[0] + '#' + (Math.random() * 100).toString().replace('.', '');
location.reload();
}
</script>

<meta name="description" content="Share files with multiple users using RTCMultiConnection" />
<meta name="keywords" content="WebRTC,RTCMultiConnection,Demos,Experiments,Samples,Examples" />

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

<link rel="author" type="text/html" href="https://plus.google.com/+MuazKhan">

<link href='https://fonts.googleapis.com/css?family=Open+Sans:300,600' rel='stylesheet' type='text/css'>
Expand All @@ -23,12 +30,12 @@
::-webkit-scrollbar {
height: 0;
overflow: visible;
width: 10px;
width: 10px;
border-left:1px solid rgb(229, 229, 229);
}
::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, .2);
background-clip: padding-box;
background-clip: padding-box;
min-height: 28px;
padding: 100px 0 0;
box-shadow: inset 1px 1px 0 rgba(0,0,0,.1),inset 0 -1px 0 rgba(0,0,0,.07);
Expand Down Expand Up @@ -279,10 +286,10 @@
// to get STUN/TURN URIs from xirsys.com
window.getExternalIceServers = true;
</script>

<!-- <script src="/dist/rmc3.min.js"></script> -->
<script src="https://cdn.webrtc-experiment.com:443/rmc3.min.js"></script>
<script src="https://cdn.webrtc-experiment.com:443/rmc3.min.js"></script>

<!-- <script src="/dev/FileBufferReader.js"></script> -->
<script src="https://cdn.webrtc-experiment.com:443/rmc3.fbr.min.js"></script>

Expand Down Expand Up @@ -329,21 +336,26 @@
}
});

var btnSelectFile = document.querySelector('.btn-select-file');
var connection;

function joinARoom(roomId) {
var iframe = document.querySelector('iframe');

var btnSelectFile = document.querySelector('.btn-select-file');
btnSelectFile.onclick = function(file) {
if(file && (file instanceof File || file instanceof Blob) && file.size) {
previewFile(file);
onFileSelected(file);
return;
}

btnSelectFile.onclick = function() {
var fileSelector = new FileSelector();
fileSelector.selectSingleFile(function(file) {
previewFile(file);

onFileSelected(file);
});
};

var connection;
var lastSelectedFile;

var room_id = '';
Expand Down Expand Up @@ -428,7 +440,7 @@
var file = lastSelectedFile;
setTimeout(function() {
appendLog('Sharing file<br><b>' + file.name + '</b><br>Size: <b>' + bytesToSize(file.size) + '<b><br>With <b>' + connection.getAllParticipants().length + '</b> users');

connection.send({
doYouWannaReceiveThisFile: true,
fileName: file.size + file.name
Expand Down Expand Up @@ -720,6 +732,30 @@
window.addEventListener('online', function() {
location.reload();
}, false);

// drag-drop support
document.addEventListener('dragover', function(e) {
e.preventDefault();
e.stopPropagation();
e.dataTransfer.dropEffect = 'copy';
}, false);

document.addEventListener('drop', function(e) {
e.preventDefault();
e.stopPropagation();

if(!e.dataTransfer.files || !e.dataTransfer.files.length) {
return;
}

var file = e.dataTransfer.files[0];

if(!connection) {
document.getElementById('join-room').onclick();
}

btnSelectFile.onclick(file);
}, false);
</script>
</body>
</html>
5 changes: 4 additions & 1 deletion dev/DetectRTC.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-09-04 3:03:44 AM UTC
// Last time updated: 2016-10-12 6:16:40 AM UTC

// Latest file can be found here: https://cdn.webrtc-experiment.com/DetectRTC.js

Expand Down Expand Up @@ -233,6 +233,9 @@
var db;
try {
db = window.indexedDB.open('test');
db.onerror = function() {
return true;
};
} catch (e) {
isPrivate = true;
}
Expand Down
Loading

0 comments on commit ca93255

Please sign in to comment.