↑ www.RTCMultiConnection.org RTCMultiConnection Log

RTCMultiConnection Docs ----/ Changes Log | FAQ | Demos!

  1. Getting Started Guide
  2. API Reference

    1. constructor
      new RTCMultiConnection('channel-id');
      
    2. session
      connection.session = {
           audio:     true, // by default, it is true
           video:     true, // by default, it is true
           screen:    false,
           
           data:      false,
           
           oneway:    false,
           broadcast: false
      };
      
    3. open method
      connection.open('room-id');
      
    4. connect method
      connection.connect('room-id');
      
    5. join method
      connection.join('room-id');
      
      // or
      var sessionDescription = {
          sessionid: 'abcdef',
          userid: 'xyz',
          extra: {},
          session: {
              audio: true,
              video: true
          }
      };
      connection.join(sessionDescription);
      
    6. isInitiator
      if(connection.isInitiator) {
          connection.close(); // close entire session
      }
      
    7. join
      connection.onNewSession = function(session) {
          session.join();                           // join session as it is!
          session.join({audio: true});              // join session while allowing only audio
          session.join({video: true});              // join session while allowing only video
          session.join({screen: true});             // join session while allowing only screen
          session.join({audio: true, video: true}); // join session while allowing both audio and video
      };
      
    8. onNewSession
      var sessions = {};
      connection.onNewSession = function (session) {
          if (sessions[session.sessionid]) return;
          sessions[session.sessionid] = session;
      
          connection.join();
      };
      
    9. channel-id
      // via constructor
      var connect = new RTCMultiConnection('channel-id');
      
      // via open/connect methods
      connection.open('channel-id');
      
      connection.connect('channel-id');
      
    10. sessionid
      connection.sessionid = 'unique-room-id';
      
    11. userid
      connection.userid = 'custom-user-id';
      
    12. send
      connection.send(file || data || 'logest-text-message');
      
    13. captureUserMedia
      var session = {
          audio: true
      };
      
      connection.captureUserMedia(function (mediaStream) { }, session);
      
    14. direction
      connection.direction = 'one-to-one';
      connection.direction = 'one-way';
      
    15. getDevices
      connection.getDevices(function(devices){
          for (var device in devices) {
              device = devices[device];
              
              // device.kind == 'audio' || 'video'
              console.log(device.id, device.label);
          }
      });
      
    16. selectDevices
      connection.selectDevices(firstDeviceID, secondDeviceID);
      
    17. interval
      connection.interval = 3000;
      
    18. transmitRoomOnce
      connection.transmitRoomOnce = false;
      
    19. maxParticipantsAllowed
      connection.maxParticipantsAllowed = 256;
      
    20. onspeaking
      connection.onspeaking = function (e) {
          // e.streamid, e.userid, e.stream, etc.
          e.mediaElement.style.border = '1px solid red';
      };
      
    21. onsilence
      
      connection.onsilence = function (e) {
          // e.streamid, e.userid, e.stream, etc.
          e.mediaElement.style.border = '';
      };
      
    22. openSignalingChannel
      connection.openSignalingChannel = function(config) {};
      
    23. session-initiator
    24. session-participant
    25. renegotiation
    26. disableDtlsSrtp
      connection.disableDtlsSrtp = false;
      
    27. addStream
      connection.addStream({
          audio: true,
          video: true
      });
      
    28. 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
      });
      
    29. attachStreams
      connection.attachStreams.push(mediaStream1, mediaStream2);
      
    30. startRecording
      connection.streams['stream-id'].startRecording({
          audio: true,
          video: true
      });
      
    31. 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} );
      
    32. detachStreams
      connection.detachStreams.push(streamid1, streamid2);
      
    33. dontAttachStream
      connection.dontAttachStream = false;
      
    34. dontCaptureUserMedia
      connection.dontCaptureUserMedia = false;
      
    35. autoCloseEntireSession
      connection.autoCloseEntireSession = false;
      
    36. autoSaveToDisk
      connection.autoSaveToDisk = false;
      
    37. bandwidth
      connection.bandwidth = {
          audio: 50,
          video: 256,
          data: 1638400
      };
      
    38. body
      <div class="container"></div>
      connection.body = document.querySelector('.container');
      
    39. candidates
      connection.candidates = {
           turn:     true,
           stun:     false,
           host:     false
      };
      
    40. channels
      connection.channels['user-id'].send(file || data || 'text');
      
    41. close
      connection.close();
      
    42. leave
      connection.leave();
      
    43. eject
      connection.eject(userid);
      
    44. onleave
      connection.onleave = function(e) {
          // e.userid
          // e.extra
      };
      
    45. onstream
      connection.onstream = function(e) {
          // e.mediaElement (audio or video element)
          // e.stream     native MediaStream object
          // e.streamid   unique identifier of the stream; it will be synced among all users!
          // 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 display audio/video elements
          document.body.appendChild(e.mediaElement);
          
          // e.isVideo ---- if it is a  Video stream
          // e.isAudio ---- if it is an Audio stream
      };
      
    46. onstreamended
      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
      }
      
    47. onMediaError
      connection.onMediaError = function (error) {
          console.error(error);
      }
      
    48. devices
      for (var device in connection.devices) {
          device = connection.devices[device];
      
          // device.kind == 'audio' || 'video'
          console.log(device.id, device.label);
      }
      
    49. extra
      connection.extra = {
          username: 'muazkh',
          fullname: 'Muaz Khan',
          email: 'muazkh@gmail.com'
      };
      
    50. fileQueue
    51. 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;
      
    52. 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;
      
    53. sdpConstraints
      connection.sdpConstraints.mandatory = {
          OfferToReceiveAudio: false,
          OfferToReceiveVideo: false,
          VoiceActivityDetection: false,
          IceRestart: true
      };
      
    54. mute
      connection.streams['stream-id'].mute({
          audio: true,
          video: true
      });
      
    55. unmute
      connection.streams['stream-id'].unmute({
          audio: true,
          video: true
      });
      
    56. 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();
      
    57. onmute
      connection.onmute = function(e) {
         e.mediaElement.setAttribute('poster', 'photo.jpg');
      };
      
    58. onunmute
      connection.onunmute = function(e) {
         e.mediaElement.removeAttribute('poster');
      };
      
    59. onmessage
      connection.onmessage = function(e) {
         // e.data
         // e.userid
         // e.extra
      };
      
    60. onopen
      connection.onopen = function(e) {
         // e.userid
         // e.extra
      };
      
    61. onclose
      connection.onclose = function(e) {
         // e.userid
         // e.extra
      };
      
    62. onerror
      connection.onerror = function(e) {
         // e.userid
         // e.extra
      };
      
    63. onFileStart
    64. onFileEnd
    65. onFileProgress
    66. 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();
      
    67. preferSCTP
      // prefer RTP and disable SCTP
      connection.preferSCTP = false;
      
    68. streams
      connection.streams.mute();
      connection.streams.unmute();
      
    69. skipRTCMultiConnectionLogs
      // You can disable all logs by setting "window.skipRTCMultiConnectionLogs" to true.
      window.skipRTCMultiConnectionLogs = true;
      
    70. firebase
      connection.firebase = 'chat';
      
    71. 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();
      
    72. onRequest
      connection.onRequest = function (request) {
          // 2nd parameter "extra" is optional
          connection.accept(request);
      };
      
    73. request
      // use "user-id" to invite a user
      connection.request('userid');
      
    74. accept
      connection.onRequest = function (request) {
          connection.accept(request);
      };
      
    75. reject
      connection.onRequest = function (request) {
          connection.reject(request);
      };
      
    76. 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
      };
      
    77. userType
      // if you want to set "admin"
      connection.userType = 'admin';
      
      // if you want to set "guest"
      connection.userType = 'guest';
      
    78. onAdmin
      connection.onAdmin = function (admin) {
          // Lets call admin using his userid
          connection.request(admin.userid);
      };
      
    79. onGuest
      connection.onGuest = function (guest) {
          // Lets call guest using his userid
          connection.request(guest.userid);
      };
      
    80. takeSnapshot
      connection.takeSnapshot('userid', function(snapshot) {
          image.src = snapshot;
      });
      
    81. 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'];
      
    82. getStats
      connection.getStats(function(stat) {
          // stat.numberOfConnectedUsers
      });
      
    83. 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);
      
    84. 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.');
          }
      });
      
    85. 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;
      
    86. drop
      connection.drop();
      
    87. ondrop
      // "ondrop" is fired; if media-connection is droppped by other user
      connection.ondrop = function() { };
      
    88. sendCustomMessage
      connection.sendCustomMessage(any_kind_of_data |or| string_message);
      
    89. onCustomMessage
      connection.onCustomMessage = function(message) { };
      
    90. remove
      connection.remove('user-id');
      
    91. refresh
      connection.refresh();
      
    92. 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;
      
    93. chunkInterval
      // for RTP-data channels; chunk-interval is 500
      connection.chunkInterval = 500;
      
      // for SCTP-data channels; chunk-interval is 100
      connection.chunkInterval = 100;
      
    94. renegotiate
      // renegotiate with/without media streams!
      connection.renegotiate(Custom_MediaStream);
      
    95. onhold
      // hold call same like skype
      connection.peers['user-id'].hold();
      
      // fired if call is on hold
      connection.onhold = function(e) {
      	// e.mediaElement
      };
      
    96. 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
      };
      
    97. 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} );
      
    98. Translator
      connection.Translator.TranslateText(textToConvert, function(convertedText) {
           console.log(convertedText);
      });
      
    99. autoTranslateText
      connection.autoTranslateText = true;
      
    100. language
      connection.language = 'ja'; // prefer Japanese
      
    101. token
      var randomString = rtcMultiConnection.token();
      rtcMultiConnection.userid = rtcMultiConnection.token();
      
    102. UA
      connection.UA.isChrome
      connection.UA.isFirefox
      connection.UA.isIE
      connection.UA.isOpera
      connection.UA.isSafari
      connection.UA.isMobileDevice
      connection.UA.version
      
    103. 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 = { };
      
    104. 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);
      };
      
    105. shareMediaFile
      // select WebM file to share as pre-recorded media!
      document.querySelector('input[type=file]').onchange = function() {
          connection.shareMediaFile( this.files[0] );
      };
      
    106. autoReDialOnFailure
      // by default, it is "false"
      // it is false because workaround that is used to capture connections' failures
      // affects renegotiation scenarios!
      connection.autoReDialOnFailure = true;
      
    107. 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;
          }
      };
      
    108. 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
              });
          }
      };
      
    109. 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;
      
    110. redial
      // to recreate offers/answers
      connection.peers['target-userid'].redial();
      
    111. 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);
      
    112. 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
      };
      
    113. 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);
          }
      };
      
    114. 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}
      };
      
    115. sharePartOfScreen method
      connection.sharePartOfScreen({
          element: '#elementToShare',
          interval: 500
      });
      
    116. 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;
      
    117. 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;
      
    118. 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
      
    119. 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
      };
      
    120. setDefaultEventsForMediaElement method
      // You can override setDefaultEventsForMediaElement to prevent 
      // default mute/unmute handlers on media elements:
      connection.setDefaultEventsForMediaElement = false;
      
    121. processSdp method
      connection.processSdp = function(sdp) {
          sdp = remove_vp8_codecs(sdp);
          sdp = prefer_opus (sdp);
          sdp = use_maxaveragebitrate(sdp);
          return sdp;
      };
      
    122. 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);
      };
      
    123. 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);
          }
      };
      
    124. 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
      });
      
    125. 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;
      };
      
    126. getExternalIceServers
      // if you want to use XirSys-based STUN/TURN servers
      connection.getExternalIceServers = true;
      
    127. waitUntilRemoteStreamStartsFlowing
      // It allows you override default 
      // Wait-Until-Remote-Stream-starts-flowing behaviour.
      connection.waitUntilRemoteStreamStartsFlowing = false;
      
    128. switchStream
      // remove all old streams and add screen in oneway.
      connection.switchStream({
          screen: true,
          oneway: true
      });
      
    129. 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) { }
      };
      
    130. 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
      });
      
    131. 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];
      }
      
    132. keepStreamsOpened
      // if you want to keep local streams to be opened
      // even if entire session is closed
      connection.keepStreamsOpened = true;
      
    133. "log" and "onlog"
      // if you want to disable logs
      connection.log = false;
      
      connection.onlog = function(log) {
          var div = document.createElement('div');
          div.innerHTML = JSON.stringify(log, null, '
      '); document.documentElement.appendChild(div); };
    134. 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
          });
      };
      
    135. getConnectionStats
      connection.peers['target-userid'].peer.getConnectionStats(function (result) {
          // many useful statistics here
      });
      
    136. onfailed
      connection.onfailed = function (event) {
          event.peer.renegotiate();
          // or event.peer.redial();
          // event.targetuser.browser == 'firefox' || 'chrome'
      };
      
    137. ondisconnected
      connection.ondisconnected = function(event) {
          // connection has been disconnected between you
          // and event.userid
      };
      
    138. iceProtocols
      connection.iceProtocols = {
          tcp: true, // prefer using TCP-candidates
          udp: true  // prefer using UDP-candidates
      };
      
    139. preventSSLAutoAllowed
      connection.preventSSLAutoAllowed = true;
      
    140. 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'
      };
      
    141. enumerateDevices
      connection.enumerateDevices(function(devices) {
          devices.forEach(function(device) {
              // device.deviceId
              // device.kind == 'audioinput' || 'audiooutput' || 'audio'
              
              connection.selectDevices(device.deviceId);
          });
      });
      
    142. 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
      });
      
    143. onMediaCaptured
      connection.open({
          onMediaCaptured: function() {
              // initiator enable camera/microphone
              // you can share "sessionDescription" with other users
              // and they can quickly join initiator!
          }
      });
      
    144. onScreenCapturingExtensionAvailable
      connection.onScreenCapturingExtensionAvailable = function() {
          btnInlineInstallButton.disabled = true;
      };
      
    145. onMediaError
      connection.onMediaError = function(error) {
          if(error.name == 'PermissionDeniedError') {
              alert(error.message);
          }
      };
      
    146. 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;
      
    147. 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;
      
    148. 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;
      


Want to ask a Question?

You can include your email for private conversation!

Latest Updates