Comments (2)
I tested socket.io over node.js with RTCMultiConnectionv-1.3
and it worked fine!
Here is the Entire Demo
<script src="https://webrtc-experiment.appspot.com/socket.io.js"></script>
<script src="https://webrtc-experiment.appspot.com/RTCMultiConnection-v1.3.js"></script>
<button id="init">Open NEW Session</button>
<table style="border-left: 1px solid black; width: 100%;">
<tr>
<td id="local-video-container">
<h2>Local video container</h2>
</td>
<td id="remote-videos-container" style="background: white; border-left: 1px solid black;">
<h2>Remote videos container</h2>
</td>
</tr>
</table>
<script>
var SIGNALING_SERVER = 'http://webrtc-signaling.jit.su:80/',
defaultChannel = 'default-channel';
window.username = Math.random() * 9999 << 9999;
var connection = new RTCMultiConnection(defaultChannel);
connection.openSignalingChannel = function(config) {
var channel = config.channel || defaultChannel;
var sender = Math.round(Math.random() * 60535) + 5000;
io.connect(SIGNALING_SERVER).emit('new-channel', {
channel: channel,
sender: sender
});
var socket = io.connect(SIGNALING_SERVER + channel);
socket.channel = channel;
socket.on('connect', function() {
if (config.callback) config.callback(socket);
});
socket.send = function(message) {
socket.emit('message', {
sender: sender,
data: message
});
};
socket.on('message', config.onmessage);
};
connection.onstream = function(e) {
if (e.type === 'local') {
var video = getVideo(e, {
username: window.username
});
document.getElementById('local-video-container').appendChild(video);
}
if (e.type === 'remote') {
var video = getVideo(e, e.extra);
var remoteVideosContainer = document.getElementById('remote-videos-container');
remoteVideosContainer.appendChild(video, remoteVideosContainer.firstChild);
}
e.mediaElement.width = innerWidth / 3.4;
};
connection.onleave = function(userid, extra) {
if (extra) console.log(extra.username + ' left you!');
var video = document.getElementById(userid);
if (video) video.parentNode.removeChild(video);
};
function getVideo(e, extra) {
var div = document.createElement('div');
div.className = 'video-container';
div.id = e.userid || 'self';
if (e.type === 'remote') {
if (connection.isInitiator) {
var eject = document.createElement('button');
eject.className = 'eject';
eject.title = 'Eject this User';
eject.onclick = function() {
connection.eject(this.parentNode.id);
this.parentNode.style.display = 'none';
};
div.appendChild(eject);
}
}
div.appendChild(e.mediaElement);
if (extra) {
var h2 = document.createElement('h2');
h2.innerHTML = 'username: ' + extra.username;
div.appendChild(h2);
}
return div;
}
document.getElementById('init').onclick = function() {
connection.interval = 1000;
connection.open();
};
connection.extra = {
username: window.username
};
connection.connect();
</script>
from webrtc-experiment.
@muaz-khan Thanks for pointing me the right direction. I must have been making some weird mistake. Everything's running smoothly now.
๐
from webrtc-experiment.
Related Issues (20)
- "WebRTC Video Conferencing Demos" link refer to nonexistant page
- screen sharing doesn't work on chrome HOT 2
- How can we control which port(s) will be used to create peer to peer connection in WebRTC? HOT 1
- ERROR - {"code":0,"message":"Transport unknown"}
- Two LED screens are spliced, and the recording recording files is 0 bytes.
- Scalable Broadcasting Camera Switch
- Stop after 5 seconds
- Test001123
- Anyone using Scalable Broadcasting in Production?
- Only users who are on the same network can communicate on socket.io
- muazkhan.com socket.io signaling server is down
- How to controller video quality ex. I want to save video only 480 or 720
- Facing issue on webrtc video conference using firebase
- Is it support G723 or G729
- Muaz is gone! HOT 1
- Conference Calling on Android
- Cleanup of getDisplayMedia demo HOT 1
- Can I share some Windows?
- Video Recording
- Can a shared surface select its derivative window๏ผ
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webrtc-experiment.