RTCMultiConnection Docs | API Reference

HOME © Muaz Khan . @WebRTCWeb . Github . Latest issues . What's New?

You can search missing API or contribute to improve these documents.
  1. Getting Started Guide
  2. Write Android apps
  3. Write iOS apps
You can watch Many YouTube RTCMultiConnection Videos as well.

API Reference

  1. constructor
    var connection = new RTCMultiConnection();
    
  2. socket object
    connection.openOrJoin();
    
    // you can access this object after starting or joining a room.
    connection.socket.emit('howdy', 'hello');
    
  3. socketURL property
    connection.socketURL = 'https://onlyChangingPort.com:8888/';
    connection.socketURL = 'https://separateDomain.com:443/';
    connection.socketURL = '/'; // same domain
    
    // or a free signaling server
    connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';
    
  4. enableLogs property
    // to disable logs
    connection.enableLogs = false;
    
  5. getAllParticipants method
    connection.getAllParticipants().forEach(function(participantId) {
      // typeof participantId === 'string'
      var peer = connection.peers[participantId];
      console.log(peer.connection, peer.userid, peer.streams, peer.channels);
    });
    
  6. session object
    connection.session = {
      audio:     true, // by default, it is true
      video:     true, // by default, it is true
      screen:    false,
    
      data:      false,
    
      oneway:    false,
      broadcast: false
    };
    
  7. open method
    connection.open( 'room-id' );
    
    // or
    connection.open( 'room-id', function() {
      alert('Room has been created.');
    });
    
    // or
    var isPublicRoom = true;
    connection.open( 'room-id', isPublicRoom );
    
  8. join method
    connection.join( 'room-id' );
    
    // or
    var password = 'xyz';
    connection.join( 'room-id', password );
    
  9. openOrJoin method
    connection.openOrJoin( 'room-id' );
    
    // or
    connection.openOrJoin( 'room-id', function(isRoomExists, roomid) {
      alert(isRoomExists ? 'You joined room' : 'You created room');
    });
    
  10. checkPresence method
    connection.checkPresence( 'room-id', function(isRoomExists, roomid) {
      if(isRoomExists) {
        connection.join(roomid);
      }
      else {
        connection.open(roomid);
      }
    });
    
  11. connectSocket method
    connection.connectSocket();
    
    // or
    connection.connectSocket( function() {
      alert('Successfully connected to socket.io server.');
    
      connection.socket.emit('howdy', 'hello');
    });
    
  12. disconnectWith method
    connection.disconnectWith( 'remote-userid' );
    
  13. onUserStatusChanged event
    connection.onUserStatusChanged = function(event) {
      var isOnline = event.status === 'online';
      var isOffline = event.status === 'offline';
    
      var targetUserId = event.userid;
      var targetUserExtraInfo = event.extra;
    };
    
  14. onstream event
    connection.onstream = function(event) {
      if (event.isScreen) {
        // screenVideo.src = event.blobURL;
        screenDiv.appendChild(event.mediaElement);
      }
    
      if (event.isAudio) {
        audioOnlyTag.src = event.blobURL;
      }
    
      if (event.isVideo) {
        // audioPlusVideo.src = event.blobURL;
        // videoOnly.src = event.blobURL;
        videoDiv.appendChild(event.mediaElement);
      }
    };
    
  15. onstreamended event
    connection.onstreamended = function (e) {
      // e.mediaElement (audio or video element)
      // e.stream     native MediaStream object
      // e.streamid   unique identifier of the stream synced from stream sender
      // e.session {audio: true, video: true}
      // e.blobURL
      // e.type     "local" or "remote"
      // e.extra
      // e.userid   the person who shared stream with you!
    
      // easiest way to remove relevant element!
      e.mediaElement.parentNode.removeChild(e.mediaElement);
    
      // e.isVideo ---- if it is a  Video stream
      // e.isAudio ---- if it is an Audio stream
    }
    
  16. setCustomSocketHandler method
    // link => /dev/globals.js
    // link => /dev/FirebaseConnection.js
    
    // below line replaces FirebaseConnection
    connection.setCustomSocketHandler(FirebaseConnection);
    
  17. updateExtraData method
    connection.updateExtraData();
    
  18. onExtraDataUpdated event
    connection.onExtraDataUpdated = function(event) {
      var extra = event.extra;
      var targetUserId = event.userid;
    };
    
  19. becomePublicModerator method
    connection.becomePublicModerator();
    
  20. getPublicModerators method
    connection.getPublicModerators( function(arrayOfModerators) {
      arrayOfModerators.forEach(function(moderator) {
        // moderator.extra
        connection.join(moderator.userid);
      });
    });
    
  21. socketCustomParameters property
    // starts with "&"
    // &fullName=Muaz
    // &meetingId=xyz
    connection.socketCustomParameters = '&fullName=Muaz&country=PK&meetingId=xyz';
    
  22. isInitiator
    if(connection.isInitiator) {
      connection.close(); // close entire session
    }
    
  23. onNewSession
    var sessions = {};
    connection.onNewSession = function (session) {
      if (sessions[session.sessionid]) return;
      sessions[session.sessionid] = session;
    
      connection.join();
    };
    
  24. connect method
    connection.connect('room-id');
    
  25. channel-id
    // via constructor
    var connect = new RTCMultiConnection('channel-id');
    
    // via open/connect methods
    connection.open('channel-id');
    
    connection.connect('channel-id');
    
  26. sessionid
    connection.sessionid = 'unique-room-id';
    
  27. userid
    connection.userid = 'custom-user-id';
    
  28. send
    connection.send(file || data || 'logest-text-message');
    
  29. streamEvents
    // you can pass: 'audio' || 'video' || 'both
    connection.streamEvents['stream-id'].stream.mute('both');
    
    // or unmute
    connection.streamEvents['stream-id'].stream.unmute('both');
    
  30. captureUserMedia
    var session = {
      audio: true
    };
    
    connection.captureUserMedia(function (mediaStream) { }, session);
    
  31. direction
    connection.direction = 'one-to-one';
    connection.direction = 'one-way';
    
  32. getDevices
    connection.getDevices(function(devices){
      for (var device in devices) {
        device = devices[device];
    
        // device.kind == 'audio' || 'video'
        console.log(device.id, device.label);
      }
    });
    
  33. selectDevices
    connection.selectDevices(firstDeviceID, secondDeviceID);
    
  34. interval
    connection.interval = 3000;
    
  35. transmitRoomOnce
    connection.transmitRoomOnce = false;
    
  36. maxParticipantsAllowed
    connection.maxParticipantsAllowed = 256;
    
  37. onspeaking
    connection.onspeaking = function (e) {
      // e.streamid, e.userid, e.stream, etc.
      e.mediaElement.style.border = '1px solid red';
    };
    
  38. onsilence
    
    connection.onsilence = function (e) {
      // e.streamid, e.userid, e.stream, etc.
      e.mediaElement.style.border = '';
    };
    
  39. openSignalingChannel
    connection.openSignalingChannel = function(config) {};
    
  40. session-initiator
  41. session-participant
  42. renegotiation
  43. disableDtlsSrtp
    connection.disableDtlsSrtp = false;
    
  44. addStream
    connection.addStream({
      audio: true,
      video: true
    });
    
  45. removeStream
    connection.removeStream('stream-id');
    
    // remove all screen streams.
    // you can use "remove all video streams" by passing "video"
    // or "remove all audio streams" by passing "audio"
    connection.removeStream('screen');
    
    // remove-all but multiple streams
    // i.e. remove all audio and video streams
    // or remove all audio and screen streams
    connection.removeStream({
      screen: true,
      audio: true
    });
    
  46. attachStreams
    connection.attachStreams.push(mediaStream1, mediaStream2);
    
  47. startRecording
    connection.streams['stream-id'].startRecording({
    audio: true,
    video: true
    });
    
  48. stopRecording
    // stop single audio stream
    connection.streams['stream-id'].stopRecording(function (blob) {
      // POST "Blob" to PHP/other server using FormData/XHR2
    }, {audio:true});
    
    // stop single video stream
    connection.streams['stream-id'].stopRecording(function (blob) {
      // POST "Blob" to PHP/other server using FormData/XHR2
    }, {video:true});
    
    // stop both audio/video streams
    connection.streams['stream-id'].stopRecording(function (audioBlob, videoBlob) {
      // POST both audio/video "Blobs" to PHP/other server using single FormData/XHR2
    }, {audio:true, video:true} );
    
  49. detachStreams
    connection.detachStreams.push(streamid1, streamid2);
    
  50. dontAttachStream
    connection.dontAttachStream = false;
    
  51. dontCaptureUserMedia
    connection.dontCaptureUserMedia = false;
    
  52. autoCloseEntireSession
    connection.autoCloseEntireSession = false;
    
  53. autoSaveToDisk
    connection.autoSaveToDisk = false;
    
  54. bandwidth
    connection.bandwidth = {
      audio: 50,
      video: 256,
      data: 1638400
    };
    
  55. body
    <div class="container"></div>
    connection.body = document.querySelector('.container');
    
  56. candidates
    connection.candidates = {
      turn:     true,
      stun:     false,
      host:     false
    };
    
  57. channels
    connection.channels['user-id'].send(file || data || 'text');
    
  58. close
    connection.close();
    
  59. leave
    connection.leave();
    
  60. eject
    connection.eject(userid);
    
  61. onleave
    connection.onleave = function(e) {
      // e.userid
      // e.extra
    };
    
  62. onMediaError
    connection.onMediaError = function (error) {
      console.error(error);
    };
    
  63. devices
    for (var device in connection.devices) {
      device = connection.devices[device];
    
      // device.kind == 'audio' || 'video'
      console.log(device.id, device.label);
    }
    
  64. extra
    connection.extra = {
      username: 'muazkh',
      fullname: 'Muaz Khan',
      email: 'muazkh@gmail.com'
    };
    
  65. fileQueue
  66. media
    // Enjoy full-hd video streaming
    connection.media.min(1920,1080);
    connection.media.max(1920,1080);
    
    // Enjoy hd video streaming
    connection.media.min(1280,720);
    connection.media.max(1280,720);
    
    // other possible values
    connection.media.min(960,720);
    connection.media.min(640,360); // -------- it is default
    connection.media.min(640,480);
    connection.media.min(320,240);
    connection.media.min(320,180);
    
    connection.media.minAspectRatio = 1.77;
    
  67. mediaConstraints
    connection.mediaConstraints.mandatory = {
      minWidth: 1280,
      maxWidth: 1280,
      minHeight: 720,
      maxHeight: 720,
      minFrameRate: 30
    };
    
    // it is same like "connection.session={audio:false}"
    connection.mediaConstraints.audio = false;
    
  68. sdpConstraints
    connection.sdpConstraints.mandatory = {
      OfferToReceiveAudio: false,
      OfferToReceiveVideo: false,
      VoiceActivityDetection: false,
      IceRestart: true
    };
    
  69. mute
    // using v2
    connection.streams['stream-id'].mute({
      audio: true,
      video: true
    });
    
    // using v3
    connection.streamEvents['stream-id'].stream.mute('both'); // 'audio' || 'video' || 'both'
    
  70. unmute
    // using v2
    connection.streams['stream-id'].unmute({
      audio: true,
      video: true
    });
    
    // using v3
    connection.streamEvents['stream-id'].stream.unmute('both'); // 'audio' || 'video' || 'both'
    
  71. stop
    // stop all local media streams
    connection.streams.stop('local');
    
    // stop all remote media streams
    connection.streams.stop('remote');
    
    // stop all media streams
    connection.streams.stop();
    
  72. onmute
    connection.onmute = function(e) {
      e.mediaElement.setAttribute('poster', 'photo.jpg');
    };
    
  73. onunmute
    connection.onunmute = function(e) {
      e.mediaElement.removeAttribute('poster');
    };
    
  74. onmessage
    connection.onmessage = function(e) {
      // e.data
      // e.userid
      // e.extra
    };
    
  75. onopen
    connection.onopen = function(e) {
      // e.userid
      // e.extra
    };
    
  76. onclose
    connection.onclose = function(e) {
    // e.userid
    // e.extra
    };
    
  77. onerror
    connection.onerror = function(e) {
      // e.userid
      // e.extra
    };
    
  78. onFileStart
  79. onFileEnd
  80. onFileProgress
  81. peers
    // add new stream to existing peer connection
    connection.peers['user-id'].addStream({
      screen: true,
      oneway: true
    });
    
    // renegotiate while adding external media streams
    connection.peers['user-id'].renegotiate(Custom_MediaStream);
    
    // renegotiate while no media stream is added
    connection.peers['user-id'].renegotiate();
    
    // change bandwidth at runtime
    connection.peers['user-id'].changeBandwidth({
      audio: 20,
      video: 30,
      data: 50
    });
    
    // send private message to target user; privacy is guaranteed!
    connection.peers['user-id'].sendCustomMessage('private-message');
    connection.peers['user-id'].onCustomMessage = function(privateMessage) {
      console.log('private custom message', privateMessage);
    };
    
    // to drop call; same like skype!
    connection.peers['user-id'].drop();
    
    // to hold call; same like skype!
    connection.peers['user-id'].hold();
    
    // to unhold call; same like skype!
    connection.peers['user-id'].unhold();
    
  82. preferSCTP
    // prefer RTP and disable SCTP
    connection.preferSCTP = false;
    
  83. streams
    connection.streams.mute();
    connection.streams.unmute();
    
  84. skipRTCMultiConnectionLogs
    // You can disable all logs by setting "window.skipRTCMultiConnectionLogs" to true.
    window.skipRTCMultiConnectionLogs = true;
    
  85. firebase
    connection.firebase = 'chat';
    
  86. Admin/Guest Scenarios
    var you = new RTCMultiConnection();
    var he = new RTCMultiConnection();
    
    you.onRequest = function (his_id) {
      // you're "quickly" accepting his invitation
      // you can show a dialog-box too; to allow
      // user accept/reject invitation
      you.accept(his_id);
    };
    
    // he is inviting you
    he.request(your_id);
    
    // following lines are necessary because we need to
    // set signaling gateways
    you.connect();
    he.connect();
    
  87. onRequest
    connection.onRequest = function (request) {
      // 2nd parameter "extra" is optional
      connection.accept(request);
    };
    
  88. request
    // use "user-id" to invite a user
    connection.request('userid');
    
  89. accept
    connection.onRequest = function (request) {
      connection.accept(request);
    };
    
  90. reject
    connection.onRequest = function (request) {
      connection.reject(request);
    };
    
  91. onstats
    connection.onstats = function (stats, callee) {
      // callee is busy
      if (stats == 'busy') {}
    
      // callee rejected the request
      if (stats == 'rejected') {}
    
      // callee accepted caller's request
      if (stats == 'accepted') {}
    
      // callee.userid || callee.extra
    };
    
  92. userType
    // if you want to set "admin"
    connection.userType = 'admin';
    
    // if you want to set "guest"
    connection.userType = 'guest';
    
  93. onAdmin
    connection.onAdmin = function (admin) {
      // Lets call admin using his userid
      connection.request(admin.userid);
    };
    
  94. onGuest
    connection.onGuest = function (guest) {
      // Lets call guest using his userid
      connection.request(guest.userid);
    };
    
  95. takeSnapshot
    connection.takeSnapshot('userid', function(snapshot) {
      image.src = snapshot;
    });
    
  96. snapshots
    // iterate over all snapshots/
    for(var snapshot in connection.snapshots) {
      snapshot = connection.snapshots[snapshot];
    }
    
    // or, to access individual snapshot later
    image.src = connection.snapshots['userid'];
    
  97. getStats
    connection.getStats(function(stat) {
      // stat.numberOfConnectedUsers
    });
    
  98. stats
    for(var stat in connection.stats) {
      console.log(stat, connection.stats[stat]);
    }
    
    // you can directly access "numberOfConnectedUsers" later like this:
    console.log(connection.stats.numberOfConnectedUsers);
    
  99. caniuse
    console.log( connection.caniuse.RTCPeerConnection );
    console.log( connection.caniuse.getUserMedia );
    console.log( connection.caniuse.AudioContext );
    console.log( connection.caniuse.ScreenSharing );
    console.log( connection.caniuse.RtpDataChannels );
    console.log( connection.caniuse.SctpDataChannels );
    
    
    connection.caniuse.checkIfScreenSharingFlagEnabled(function (isFlagEnabled, warning) {
      if (isFlagEnabled) {
        console.error('Multi-capturing of screen is not allowed. Capturing process is denied. Try chrome >= M31.');
      }
    
      if (warning) console.error(warning);
    
      else if (!isFlagEnabled) {
        console.error('It seems that "Enable screen capture support in getUserMedia" flag is not enabled.');
      }
    });
    
  100. iceServers
    var iceServers = [];
    
    // STUN server
    iceServers.push({
      url: 'stun:23.21.150.121:3478'
    });
    
    // TURN server
    iceServers.push({
      url: 'turn:turn.bistri.com:80',
      credential: 'homeo',
      username: 'homeo'
    });
    
    connection.iceServers = iceServers;
    
  101. optionalArgument
    connection.optionalArgument = {
      optional: [{
        DtlsSrtpKeyAgreement: true
      }, {
        googImprovedWifiBwe: true
      }, {
        googScreencastMinBitrate: 300
      }],
      mandatory: {}
    };
    
  102. dataChannelDict
    connection.dataChannelDict = {
      maxRetransmits: 0,
      ordered: false,
      outOfOrderAllowed: false
    };
    
  103. drop
    connection.drop();
    
  104. ondrop
    // "ondrop" is fired; if media-connection is droppped by other user
    connection.ondrop = function() { };
    
  105. sendCustomMessage
    connection.sendCustomMessage(any_kind_of_data |or| string_message);
    
  106. onCustomMessage
    connection.onCustomMessage = function(message) { };
    
  107. remove
    connection.remove('user-id');
    
  108. refresh
    connection.refresh();
    
  109. chunkSize
    // for chrome-to-chrome data streaming only!
    connection.chunkSize = 64 * 1000;
    
    // default value is 15k because Firefox's receiving limit is 16k!
    connection.chunkSize = 15 * 1000;
    
  110. chunkInterval
    // for RTP-data channels; chunk-interval is 500
    connection.chunkInterval = 500;
    
    // for SCTP-data channels; chunk-interval is 100
    connection.chunkInterval = 100;
    
  111. renegotiate
    // renegotiate with/without media streams!
    connection.renegotiate(Custom_MediaStream);
    
  112. onhold
    // hold call same like skype
    connection.peers['user-id'].hold();
    
    // fired if call is on hold
    connection.onhold = function(e) {
      // e.mediaElement
    };
    
  113. onunhold
    // unhold call same like skype
    connection.peers['user-id'].unhold();
    
    // fired if call is resumed from hold state
    connection.onunhold = function(e) {
      // e.mediaElement
    };
    
  114. saveToDisk
    // "fileName" is optional
    connection.saveToDisk(fileURL, fileName);
    
    // you can save recorded blob to disk like this:
    connection.streams['stream-id'].stopRecording(function (audioBlob, videoBlob) {
      connection.saveToDisk(audioBlob);
      connection.saveToDisk(videoBlob);
    }, {audio:true, video:true} );
    
  115. Translator
    connection.Translator.TranslateText(textToConvert, function(convertedText) {
      console.log(convertedText);
    });
    
  116. autoTranslateText
    connection.autoTranslateText = true;
    
  117. language
    connection.language = 'ja'; // prefer Japanese
    
  118. token
    var randomString = rtcMultiConnection.token();
    rtcMultiConnection.userid = rtcMultiConnection.token();
    
  119. UA
    connection.UA.isChrome
    connection.UA.isFirefox
    connection.UA.isIE
    connection.UA.isOpera
    connection.UA.isSafari
    connection.UA.isMobileDevice
    connection.UA.version
    
  120. fakeDataChannels
    // 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 = { };
    
  121. onMediaFile
    // receive WebM files
    connection.onMediaFile = function(e) {
      // e.mediaElement (it is video-element)
      // e.userid
      // e.extra
    
      yourExistingVideoElement.src = e.mediaElement.src;
    
      // or
      document.body.appendChild(e.mediaElement);
    };
    
  122. shareMediaFile
    // select WebM file to share as pre-recorded media!
    document.querySelector('input[type=file]').onchange = function() {
      connection.shareMediaFile( this.files[0] );
    };
    
  123. autoReDialOnFailure
    // by default, it is "false"
    // it is false because workaround that is used to capture connections' failures
    // affects renegotiation scenarios!
    connection.autoReDialOnFailure = true;
    
  124. isAcceptNewSession
    // Using "isAcceptNewSession", you can allow single user to join multiple rooms from the same channel:
    connection.onstream = function(event) {
      if(event.type == 'remote') {
        // set "isAcceptNewSession=true" so this user can get and join new session i.e. room
        // it means that "onNewSession" will be fired for this user as soon as other room is available!
        connection.isAcceptNewSession = true;
      }
    };
    
  125. askToShareParticipants
    // Useful in multi-broadcasters and many viewers scenarios!
    connection.onstream = function (e) {
      if (e.type == 'remote' && role == 'Anonymous Viewer') {
        // because "viewer" joined room as "oneway:true"
        // initiator will NEVER share participants
        // to manually ask for participants;
        // call "askToShareParticipants" method.
        connection.askToShareParticipants();
      }
    
      // if you're moderator
      // if stream-type is 'remote'
      // if target user is broadcaster!
      if (connection.isInitiator && e.type == 'remote' && !e.session.oneway) {
        // call "shareParticipants" to manually share participants with all connected users!
        connection.shareParticipants({
          dontShareWith: e.userid
        });
      }
    };
    
  126. dontOverrideSession
    // dont-override-session allows you force RTCMultiConnection
    // to not override default session of participants;
    // by default, session is always overridden and set to the session coming from initiator!
    connection.dontOverrideSession = true;
    
  127. redial
    // to recreate offers/answers
    connection.peers['target-userid'].redial();
    
  128. leaveOnPageUnload boolean
    // if you want to prevent/override/bypass default behaviour
    connection.leaveOnPageUnload = false;
    
    // display a notification box
    window.addEventListener('beforeunload', function () {
      return 'Are you want to leave?';
    }, false);
    
    // leave here
    window.addEventListener('unload', function () {
      connection.leave();
    }, false);
    
  129. DetectRTC object
    if(connection.DetectRTC.hasMicrophone) {
      // seems current system has at least one audio input device
    }
    
    if(connection.DetectRTC.hasSpeakers) {
      // seems current system has at least one audio output device
    }
    
    if(connection.DetectRTC.hasWebcam) {
      // seems current system has at least one video input device
    }
    
    // to iterate over all available media devices
    connection.getDevices(function() {
      connection.DetectRTC.MediaDevices.forEach(function(device) {
        // device.deviceId
        // device.kind == 'audioinput' || 'audiooutput' || 'audio'
    
        connection.selectDevices(device.deviceId);
      });
    });
    
    // set type of capturing API
    connection.DetectRTC.screen.chromeMediaSource = 'desktop'; // screen || desktop
    
    connection.DetectRTC.screen.isChromeExtensionAvailable(function(available){
      // available == true or false
    });
    
    var extensionid = 'ajhifddimkapgcifgcodmmfdlknahffk';
    connection.DetectRTC.screen.getChromeExtensionStatus(extensionid, function(status) {
      if(status == 'installed-enabled') {
        // chrome extension is installed & enabled.
      }
    
      if(status == 'installed-disabled') {
        // chrome extension is installed but disabled.
      }
    
      if(status == 'not-installed') {
        // chrome extension is not installed
      }
    
      if(status == 'not-chrome') {
        // using non-chrome browser
      }
    });
    
    // if following function is defined, it will be called if screen capturing extension seems available
    connection.DetectRTC.screen.onScreenCapturingExtensionAvailable = function() {
      // hide inline-install button
    };
    
  130. onstatechange event
    connection.onstatechange = function (state) {
      // state.userid == 'target-userid' || 'browser'
      // state.extra  == 'target-user-extra-data' || {}
      // state.name  == 'short name'
      // state.reason == 'longer description'
      if(state.name == 'stop-request-denied') {
        alert(state.reason);
      }
    };
    
  131. onSessionClosed event
    connection.onSessionClosed = function(e) {
      // entire session is closed
    
      // e.userid
      // e.extra
      // e.isSessionClosed
    
      // e.session == connection.sessionDescription
      // e.session.sessionid
      // e.session.userid --- initiator id
      // e.session.session -- {audio:true, video:true}
    };
    
  132. sharePartOfScreen method
    connection.sharePartOfScreen({
      element: '#elementToShare',
      interval: 500
    });
    
  133. stopSharingPartOfScreen method
    // stop part of screen between all users
    connection.stopPartOfScreenSharing();
    
    // or, stop part of screen between two users
    connection.peers['target-userid'].stopPartOfScreenSharing = true;
    
  134. pausePartOfScreenSharing method
    // pause part of screen between all users
    connection.pausePartOfScreenSharing();
    
    // or, pause part of screen between two users
    connection.peers['target-userid'].pausePartOfScreenSharing = true;
    
  135. resumePartOfScreenSharing method
    // resume part of screen between all users
    connection.resumePartOfScreenSharing();
    
    // or, resume part of screen between two users
    connection.peers['target-userid'].pausePartOfScreenSharing = false;
    connection.partOfScreen.sharing = true; // necessary
    
  136. onpartofscreen
    var image = document.getElementById('preview-image');
    connection.onpartofscreen = function (event) {
      image.src = event.screenshot;
    
      // event.userid --- sender id
      // event.extra  --- extra data from sender
    };
    
  137. setDefaultEventsForMediaElement method
    // You can override setDefaultEventsForMediaElement to prevent
    // default mute/unmute handlers on media elements:
    connection.setDefaultEventsForMediaElement = false;
    
  138. processSdp method
    connection.processSdp = function(sdp) {
      sdp = remove_vp8_codecs(sdp);
      sdp = prefer_opus (sdp);
      sdp = use_maxaveragebitrate(sdp);
      return sdp;
    };
    
  139. onstreamid event
    // on getting remote stream's clue
    connection.onstreamid = function (e) {
      var mediaElement = document.createElement(e.isAudio ? 'audio' : 'video');
      mediaElement.controls = true;
      mediaElement.poster = connection.resources.muted;
      mediaElement.id = e.streamid;
      connection.body.appendChild(mediaElement);
    };
    
  140. privileges
    // set it "false" if you want to restrict user to stop/mute remote stream
    // if user will try to programmatically invoke "stop" or "mute" method,
    // you'll be informed in the "onstatechange" event.
    connection.privileges = {
      canStopRemoteStream: true, // user can stop remote streams
      canMuteRemoteStream: true  // user can mute remote streams
    };
    
    connection.onstatechange = function(state) {
      if(state.name == 'stop-request-denied') {
        alert(state.reason);
      }
    
      if(state.name == 'mute-request-denied') {
        alert(state.reason);
      }
    };
    
  141. mute
    // mute all remote audio-only streams.
    connection.streams.mute({
      isAudio: true,
      remote: true
    });
    
    // unmute all local screen streams.
    connection.streams.unmute({
      isScreen: true,
      local: true
    });
    
  142. preferJSON
    // Remember: it doesn't applies to file sharing.
    // it applies to all other kinds of data.
    connection.preferJSON = false;
    
    // send array buffer
    connection.send( new ArrayBuffer(10) );
    
    // get array buffer
    connection.onmessage =  function(event) {
      var buffer = event.data;
    };
    
  143. getExternalIceServers
    // if you want to use XirSys-based STUN/TURN servers
    connection.getExternalIceServers = true;
    
  144. waitUntilRemoteStreamStartsFlowing
    // It allows you override default
    // Wait-Until-Remote-Stream-starts-flowing behaviour.
    connection.waitUntilRemoteStreamStartsFlowing = false;
    
  145. switchStream
    // remove all old streams and add screen in oneway.
    connection.switchStream({
      screen: true,
      oneway: true
    });
    
  146. disconnect
    // it means that:
    // 1) close all sockets
    // 2) close all peers
    // 3) clear all data
    // 4) refresh everything
    // Note: local streams will be kept in "localStreams" object if "keepStreamsOpened" boolean is used.
    connection.disconnect();
    
    // it fires:
    connection.ondisconnected = function(event) {
      if(event.isSocketsDisconnected == true) { }
    };
    
  147. stop
    // stop any single stream: audio or video or screen
    connection.streams.stop('screen');
    
    // stop multiple streams
    connection.streams.stop({
      remote: true,
      video: true,
      screen: true
    });
    
  148. localStreams
    // All local streams are always kept in this object even
    // if session is closed. Look at above section
    // i.e. keepStreamsOpened.
    var stream = connection.localStreams['streamid'];
    
    // or
    connection.onSessionClosed = function() {
      var stream = connection.localStreams['streamid'];
    };
    
    // or
    for(var streamid in connection.localStreams) {
      var stream = connection.localStreams[streamid];
    }
    
  149. keepStreamsOpened
    // if you want to keep local streams to be opened
    // even if entire session is closed
    connection.keepStreamsOpened = true;
    
  150. "log" and "onlog"
    // if you want to disable logs
    connection.log = false; // usign v2
    connection.enableLogs = false; // using v3
    
    // "onlog" is available only on v2 and earlier
    connection.onlog = function(log) {
      var div = document.createElement('div');
      div.innerHTML = JSON.stringify(log, null, '
    '); document.documentElement.appendChild(div); };
  151. onconnected
    connection.onconnected = function (event) {
      log('Peer connection has been established between you and', event.userid);
    
      // event.peer.addStream || event.peer.removeStream || event.peer.changeBandwidth
      // event.peer == connection.peers[event.userid]
    
      event.peer.getConnectionStats(function (result) {
        // many useful statistics here
      });
    };
    
  152. ondisconnected
    connection.ondisconnected = function(event) {
      // connection has been disconnected between you
      // and event.userid
    };
    
  153. getConnectionStats
    connection.peers['target-userid'].peer.getConnectionStats(function (result) {
      // many useful statistics here
    });
    
  154. onfailed
    connection.onfailed = function (event) {
    event.peer.renegotiate();
    // or event.peer.redial();
    // event.targetuser.browser == 'firefox' || 'chrome'
    };
    
  155. iceProtocols
    connection.iceProtocols = {
      tcp: true, // prefer using TCP-candidates
      udp: true  // prefer using UDP-candidates
    };
    
  156. preventSSLAutoAllowed
    connection.preventSSLAutoAllowed = true;
    
  157. resources
    connection.resources = {
      RecordRTC: 'https://www.webrtc-experiment.com/RecordRTC.js',
      PreRecordedMediaStreamer: 'https://www.rtcmulticonnection.org/PreRecordedMediaStreamer.js',
      customGetUserMediaBar: 'https://www.webrtc-experiment.com/navigator.customGetUserMediaBar.js',
      html2canvas: 'https://www.webrtc-experiment.com/screenshot.js',
      hark: 'https://www.rtcmulticonnection.org/hark.js',
      firebase: 'https://www.rtcmulticonnection.org/firebase.js',
      firebaseio: 'https://chat.firebaseIO.com/',
      muted: 'https://www.webrtc-experiment.com/images/muted.png'
    };
    
  158. enumerateDevices
    connection.enumerateDevices(function(devices) {
      devices.forEach(function(device) {
        // device.deviceId
        // device.kind == 'audioinput' || 'audiooutput' || 'audio'
    
        connection.selectDevices(device.deviceId);
      });
    });
    
  159. captureUserMediaOnDemand
    // it is "disabled" by default
    // captureUserMediaOnDemand means that "getUserMedia" API for initiator will
    // be invoked only when required.
    // i.e. when first participant is detected.
    
    // you can enable it by setting it to "true"
    connection.open({
      captureUserMediaOnDemand: true
    });
    
  160. onMediaCaptured
    connection.open({
      onMediaCaptured: function() {
        // initiator enable camera/microphone
        // you can share "sessionDescription" with other users
        // and they can quickly join initiator!
      }
    });
    
  161. onScreenCapturingExtensionAvailable
    connection.onScreenCapturingExtensionAvailable = function() {
      btnInlineInstallButton.disabled = true;
    };
    
  162. onMediaError
    connection.onMediaError = function(error) {
      if(error.name == 'PermissionDeniedError') {
        alert(error.message);
      }
    };
    
  163. trickleIce
    // to ask RTCMultiConnection to wait until all ICE candidates
    // are gathered; and all ice are merged in the SDP
    // you JUST need to share that SDP "only"!
    connection.trickleIce = false;
    
  164. dontOverrideSession
    // dont-override-session allows you force RTCMultiConnection
    // to not override default session of participants;
    // by default, session is always overridden and set to the session coming from initiator!
    connection.dontOverrideSession = true;
    
  165. autoReDialOnFailure
    // by default, it is "false" for v1.9 or earlier
    // it is true for v2.0 or newer
    // it is false because workaround that is used to capture connections' failures
    // affects renegotiation scenarios!
    connection.autoReDialOnFailure = true;
    
  166. rtcConfiguration
    connection.rtcConfiguration = {
      iceServers: [],
      iceTransports: 'all'
    };
    
  167. attachExternalStream
    navigator.webkitGetUserMedia({
      video: {
        chromeMediaSource: 'screen'
      }
    }, function(stream) {
      connection.attachExternalStream(stream, true);
    }, function(error) {
      alert(JSON.stringify(error));
    });
    

Latest Issues

Want to ask a Question?

You can include your email for private conversation!

Latest Updates