Skip to content

Commit

Permalink
Updated to use latest socket.io and DetectRTC. #277
Browse files Browse the repository at this point in the history
// to test on LAN
connection.iceServers = [];

https://rtcmulticonnection.herokuapp.com is NOT using latest updates
yet (out of socket.io incompatibility). All (heroic link) users have to
use (upgrade to) /socket.io/socket.io.js instead of using
CDN.WebRTC-Experiment.com/socket.io.js
  • Loading branch information
muaz-khan committed Nov 2, 2016
1 parent 1caa3ab commit b023ff2
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 44 deletions.
4 changes: 3 additions & 1 deletion Signaling-Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ module.exports = exports = function(app, socketCallback) {

socket.on('disconnect', function() {
try {
delete socket.namespace.sockets[this.id];
if(socket && socket.namespace && socket.namespace.sockets) {
delete socket.namespace.sockets[this.id];
}
} catch (e) {
pushLogs('disconnect', e);
}
Expand Down
33 changes: 16 additions & 17 deletions dev/DetectRTC.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-10-12 6:16:40 AM UTC
// Last time updated: 2016-11-02 8:56:06 AM UTC

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

Expand Down Expand Up @@ -672,11 +672,22 @@
audioOutputDevices = [];
videoInputDevices = [];

// to prevent duplication
var alreadyUsedDevices = {};

navigator.enumerateDevices(function(devices) {
devices.forEach(function(_device) {
var device = {};
for (var d in _device) {
device[d] = _device[d];
try {
if (typeof _device[d] !== 'function') {
device[d] = _device[d];
}
} catch (e) {}
}

if (alreadyUsedDevices[device.deviceId]) {
return;
}

// if it is MediaStreamTrack.getSources
Expand All @@ -688,17 +699,6 @@
device.kind = 'videoinput';
}

var skip;
MediaDevices.forEach(function(d) {
if (d.id === device.id && d.kind === device.kind) {
skip = true;
}
});

if (skip) {
return;
}

if (!device.deviceId) {
device.deviceId = device.id;
}
Expand Down Expand Up @@ -749,10 +749,9 @@
}

// there is no 'videoouput' in the spec.
MediaDevices.push(device);

if (MediaDevices.indexOf(device) === -1) {
MediaDevices.push(device);
}
alreadyUsedDevices[device.deviceId] = device;
});

if (typeof DetectRTC !== 'undefined') {
Expand Down Expand Up @@ -837,7 +836,7 @@
if (item in window) {
webAudio.isSupported = true;

if ('createMediaStreamSource' in window[item].prototype) {
if (window[item] && 'createMediaStreamSource' in window[item].prototype) {
webAudio.isCreateMediaStreamSourceSupported = true;
}
}
Expand Down
5 changes: 5 additions & 0 deletions dev/RTCPeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,16 @@ function PeerInitiator(config) {
iceTransports = 'relay';
}
}

peer = new RTCPeerConnection(navigator.onLine ? {
iceServers: connection.iceServers,
iceTransportPolicy: connection.iceTransportPolicy || iceTransports,
rtcpMuxPolicy: connection.rtcpMuxPolicy || 'negotiate'
} : null, window.PluginRTC ? null : connection.optionalArgument);

if (!connection.iceServers.length) {
peer = new RTCPeerConnection(null, null);
}
} else {
peer = config.peerRef;
}
Expand Down
40 changes: 22 additions & 18 deletions dist/RTCMultiConnection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-10-30 4:36:48 PM UTC
// Last time updated: 2016-11-02 10:24:02 AM UTC

// _________________________
// RTCMultiConnection v3.4.1
Expand Down Expand Up @@ -2743,7 +2743,7 @@
};
}

// Last time updated: 2016-10-12 6:16:40 AM UTC
// Last time updated: 2016-11-02 8:56:06 AM UTC

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

Expand Down Expand Up @@ -3417,11 +3417,22 @@
audioOutputDevices = [];
videoInputDevices = [];

// to prevent duplication
var alreadyUsedDevices = {};

navigator.enumerateDevices(function(devices) {
devices.forEach(function(_device) {
var device = {};
for (var d in _device) {
device[d] = _device[d];
try {
if (typeof _device[d] !== 'function') {
device[d] = _device[d];
}
} catch (e) {}
}

if (alreadyUsedDevices[device.deviceId]) {
return;
}

// if it is MediaStreamTrack.getSources
Expand All @@ -3433,17 +3444,6 @@
device.kind = 'videoinput';
}

var skip;
MediaDevices.forEach(function(d) {
if (d.id === device.id && d.kind === device.kind) {
skip = true;
}
});

if (skip) {
return;
}

if (!device.deviceId) {
device.deviceId = device.id;
}
Expand Down Expand Up @@ -3494,10 +3494,9 @@
}

// there is no 'videoouput' in the spec.
MediaDevices.push(device);

if (MediaDevices.indexOf(device) === -1) {
MediaDevices.push(device);
}
alreadyUsedDevices[device.deviceId] = device;
});

if (typeof DetectRTC !== 'undefined') {
Expand Down Expand Up @@ -3582,7 +3581,7 @@
if (item in window) {
webAudio.isSupported = true;

if ('createMediaStreamSource' in window[item].prototype) {
if (window[item] && 'createMediaStreamSource' in window[item].prototype) {
webAudio.isCreateMediaStreamSourceSupported = true;
}
}
Expand Down Expand Up @@ -3891,11 +3890,16 @@
iceTransports = 'relay';
}
}

peer = new RTCPeerConnection(navigator.onLine ? {
iceServers: connection.iceServers,
iceTransportPolicy: connection.iceTransportPolicy || iceTransports,
rtcpMuxPolicy: connection.rtcpMuxPolicy || 'negotiate'
} : null, window.PluginRTC ? null : connection.optionalArgument);

if (!connection.iceServers.length) {
peer = new RTCPeerConnection(null, null);
}
} else {
peer = config.peerRef;
}
Expand Down
10 changes: 5 additions & 5 deletions dist/RTCMultiConnection.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"muaz-khan"
],
"dependencies": {
"socket.io": "0.9.17"
"socket.io": "latest"
},
"analyze": false,
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ function serverHandler(request, response) {
html += '<ol>';

docs.forEach(function(f) {
if(f.indexOf('DS_Store') == -1) {
html += '<li><a href="/~https://github.com/muaz-khan/RTCMultiConnection/tree/master/docs/' + f + '">' + f + '</a></li>';
if (f.indexOf('DS_Store') == -1) {
html += '<li><a href="/~https://github.com/muaz-khan/RTCMultiConnection/tree/master/docs/' + f + '">' + f + '</a></li>';
}
});

Expand Down

0 comments on commit b023ff2

Please sign in to comment.