↑ WEBRTC EXPERIMENTS

File Sharing + Text Chat using RTCMultiConnection

Copyright © 2013 Muaz Khan<@muazkh>.

Open Data Channel

or join:

Text Chat

Share Files



Getting started with RTCMultiConnection

<script src="https://www.webrtc-experiment.com/RTCMultiConnection-v1.3.js"></script>
<script>
    var connection = new RTCMultiConnection();
	
    connection.session = {
        data: true
    };

    // to create/open a new session
    connection.open('session-id');
	
    // if someone already created a session; to join it: use "connect" method
    connection.connect('session-id');
	
	// to send text/data or file
    connection.send(file || data || 'text');
</script>
Remember, A-to-Z, everything is optional! You can set session-id in constructor or in open/connect methods. It is your choice!

Features:

  1. Share file directly — of any size
  2. Share text-message of any length
  3. Share data directly


Additional:

<script>
    // to be alerted on data ports get open
    connection.onopen = function(e) {}
	
    // to be alerted on data ports get new message
    connection.onmessage = function(e) {}

    // show progress bar!
    connection.onFileProgress = function (packets) {
        // packets.remaining
        // packets.sent
        // packets.received
        // packets.length
    };

    // on file successfully sent
    connection.onFileSent = function (file) {
        // file.name
        // file.size
    };

    // on file successfully received
    connection.onFileReceived = function (fileName) {};
</script>


Errors Handling

<script>
    // error to open data ports
    connection.onerror = function(e) {}
	
    // data ports suddenly dropped
    connection.onclose = function(e) {}
</script>


Source code and Documentation on Github!



Feedback