←HOME

RTCDataConnection Test / Other Demos

Copyright © 2013 Muaz Khan<@muazkh>.



How to use RTCDataConnection? Documentation

<script src="https://bit.ly/RTCDataConnection-v1-0"></script>
var rtcDataConnection = new RTCDataConnection({
    onmessage: function (data) {
        console.log(data);
    },
    openSignalingChannel: function (config) {
        // How to use your own socket.io implementation?
    },
	
    // 'one-to-one' or 'one-to-many' or 'many-to-many'
    direction: 'one-to-many'
});

// Only session initiator should call below line; 
// All other 10000 room participants don't need to call "initDataConnection"!
rtcDataConnection.initDataConnection();

// to send file/data /or text
var file = inputFile.files[0];
rtcDataConnection.send( file );

rtcDataConnection.send( data );
rtcDataConnection.send( 'text' );