- https://www.webrtc-experiment.com/docs/WebRTC-Signaling-Concepts.html
- http://www.RTCMultiConnection.org/FAQ/
- http://www.RTCMultiConnection.org/docs/sessionid/
- http://www.RTCMultiConnection.org/docs/channel-id/
=
Realtime/Working WebRTC Experiments & Signaling
=
var SIGNALING_SERVER = 'http://socketio-over-nodejs.hp.af.cm';
connection.openSignalingChannel = function(config) {
var channel = config.channel || this.channel || 'one-to-one-video-chat';
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);
};
=
Your server-side node.js code looks like this:
io.sockets.on('connection', function (socket) {
socket.on('message', function (data) {
socket.broadcast.emit('message', data);
});
});
And to override openSignalingChannel
on the client side:
connection.openSignalingChannel = function(callback) {
return io.connect().on('message', callback);
};
Want to use XHR, WebSockets, SIP, XMPP, etc. for signaling? Read this post.
=
Want to use Firebase for signaling?
connection.openSignalingChannel = function (config) {
var channel = config.channel || location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');
var socket = new Firebase('https://chat.firebaseIO.com/' + channel);
socket.channel = channel;
socket.on('child_added', function (data) {
config.onmessage(data.val());
});
socket.send = function(data) {
this.push(data);
};
config.onopen && setTimeout(config.onopen, 1);
socket.onDisconnect().remove();
return socket;
};
=
Want to use PubNub for signaling?
connection.openSignalingChannel = function (config) {
var channel = config.channel || location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');
var socket = io.connect('https://pubsub.pubnub.com/' + channel, {
publish_key: 'demo',
subscribe_key: 'demo',
channel: config.channel || channel,
ssl: true
});
socket.channel = channel;
if (config.onopen) socket.on('connect', config.onopen);
socket.on('message', config.onmessage);
return socket;
};
=
Interested to understand WebRTC Signaling Concepts? Read this document.
=
WebRTC Experiments are released under MIT licence . Copyright (c) 2013 Muaz Khan.