MenuMenu

RTCMultiConnection.chunkSize

Manage how your files are splitted into chunks

Usage

// both chrome/firefox now accepts 64 kilo-bits for each data-chunk
connection.chunkSize = 60 * 1000;

// to make sure it works on all devices
connection.chunkSize = 15 * 1000;

Description

Your file will be converted into pieces.
Pieces will be delivered (shared) in linear order.
Each piece must be considered as a "data-chunk".
Both chrome and firefox allows you share 64 kilo-bits of data packets.
So you can set "chunkSize" to be either 64k or lower. Higher the value faster the streaming will be.

Demo

<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script>
<script src="https://cdn.webrtc-experiment.com/FileBufferReader.js"></script>

<script>
var connection = new RTCMultiConnection();

// this line is VERY_important
connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';

connection.enableFileSharing = true;
connection.chunkSize = 15 * 1000; // using 15k

connection.onopen = function() {
    if (connection.isInitiator == false) return;

    var selector = new FileSelector();
    selector.selectSingleFile(function(file) {
        connection.send(file);
    });
};

// if you want to open data channels
connection.session = {
    data: true
};

connection.openOrJoin('your-room-id');
</script>