WebRTC Group File Sharing using RTCDataChannel APIs! & WebSync as Signaling GateWay!

© 2013 Muaz Khan<@muazkh> » @WebRTC Experiments » Google+ » What's New?

A file-hangout experiment where all participants can share files in a group!

Private file-hangout ?? /file-hangout/#123456789

You can try SCTP based WebRTC File Sharing Demo!

How to use WebSync for Signaling?

// ------------------------------------------------------------------
// start-using WebSync for signaling
var channels = {};
var username = Math.round(Math.random() * 60535) + 5000;

var client = new fm.websync.client('websync.ashx');

client.setAutoDisconnect({
    synchronous: true
});

client.connect({
    onSuccess: function () {
        client.join({
            channel: '/chat',
            userId: username,
            userNickname: username,
            onReceive: function (event) {
                var message = JSON.parse(event.getData().text);
                if (channels[message.channel] && channels[message.channel].onmessage) {
                    channels[message.channel].onmessage(message.message);
                }
            }
        });
    }
});

function openSocket(config) {
    var channel = config.channel || 'video-conferencing';
    channels[channel] = config;

    if (config.onopen) setTimeout(config.onopen, 1000);
    return {
        send: function (message) {
            client.publish({
                channel: '/chat',
                data: {
                    username: username,
                    text: JSON.stringify({
                        message: message,
                        channel: channel
                    })
                }
            });
        }
    };
}
// end-using WebSync for signaling
// ------------------------------------------------------------------

var config = {
     openSocket: openSocket,
     onRemoteStream: function() {},
     onRoomFound: function() {}
};

How file-sharing experiment works?

  1. Multi-peers for group data connectivity
  2. Multip-sockets for group offer/answer exchange
  3. Multi SCTP/RTP data ports on single chrome/firefox instance
  4. Custom file sharing implementation for chrome
  5. In reality, it is peer-to-peer-to-peers....

Interested to learn how to share files using RTCDataChannel APIs?

Suggestions

  1. If you're newcomer, newbie or beginner; you're suggested to try RTCMultiConnection.js or DataChannel.js libraries.

Latest Updates

Feedback

Enter your email too; if you want "direct" reply!
Web hosting by Somee.com