RTCMultiConnection Docs

RTCMultiConnection API Reference / "fakeDataChannels" object

  1. Using "fakeDataChannels" object you can setup fake data connection while you're sharing audio/video/screen. You can do text-chat; share files; etc. without using WebRTC data channels.
  2. // audio+video and fake data connection
    connection.fakeDataChannels = true;
    connection.session = { audio: true, video: true };
    
    // only fake data connection; no audio; no video; no WebRTC data channel!
    connection.fakeDataChannels = true;
    connection.session = { };         
    
  3. // now, you can send file/data or text messages
    connection.send(file || data || 'longest-text-message');
    
    // how to share files
    document.querySelector('input[type=file]').onchange = function() {
        connection.send(this.files[0]);
    };
    
    // you can receive fake data messages using same "onmessage" event
    connection.onmessage = function(e) {
       // e.data     ---- translated text
       // e.original ---- original text
       // e.userid
       // e.extra
    };
    
    // same event i.e."onopen" is fired if fake data connection is opened
    connection.onopen = function (e) {
        // e.userid
        // e.extra
    };
    
  4. You can open real WebRTC data connection by renegotiating data stream:
  5. connection.addStream({
        data: true
    });
    
  6. It is possible to setup fake peer connection on chrome; where no media stream is attached; even no data ports are opened; i.e. 100% fake peer connection!
  7. Here is an example of fake peer connection:
  8. var connection = new RTCMultiConnection();
    connection.fakeDataChannels = true;
    
    // below line MUST be set to an empty object
    connection.session = {};
    
    // you can capture fake data events
    connection.onmessage = function(e) { };
    connection.onopen = function (e) { };
    
    connection.open();
    // or
    connection.connect();
    

Want to ask a Question?

You can include your email for private conversation!