Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "webrtc-adapter in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'webrtc-adapter' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

applyScreenWorkaround() {
        // use polyfill in Firefox for now, see:
        // https://blog.mozilla.org/webrtc/getdisplaymedia-now-available-in-adapter-js/
        if (adapter.browserDetails.browser === 'firefox') {
            adapter.browserShim.shimGetDisplayMedia(window, 'screen');
        }
    },
* @property {number} [minVersion] - current browser's minimum supported version
 * @property {boolean} compatible - is current browser supported ?
 */
const browser = Object.assign({
  compatible: !/\s/.test(adapter.browserDetails.browser)
    && (!adapter.browserDetails.minVersion
      || adapter.browserDetails.version >= adapter.browserDetails.minVersion)
}, adapter.browserDetails);

const version = `Reach v${SDK_VERSION} | Schema ${SCHEMA_VERSION} | Webcom v${Webcom.SDK_VERSION}`; // eslint-disable-line no-undef
let message = '';
if (browser.version === null) {
  message = 'Unsupported browser: browser must support WebRTC Peer-to-peer connections to use Reach';
} else if (browser.minVersion && browser.minVersion > browser.version) {
  message = `Unsupported browser: browser is outdated, update to latest version (${browser.minVersion}+)`;
} else if (!adapter.browserShim) {
  message = 'No shim for your browser. There might a problem with your package.';
}

// Log browser status & SDKs versions on load
let args = [`${version} ${message}`];
if (/^(chrome|firefox)$/.test(browser.browser)) {
  args = [
    `%c ${version} %c ${message}`,
    `background: ${browser.compatible ? 'blue' : 'red'}; color: #fff; font-weight: bold`,
    `color: ${browser.compatible ? 'inherit' : 'red'}`
  ];
}

console.log(...args); // eslint-disable-line no-console

export default browser;
import adapter from 'webrtc-adapter';
import Webcom from 'webcom/webcom';

/**
 * The current browser's infos
 * @typedef {Object} Browser
 * @property {string} name - current browser's name
 * @property {number} [version] - current browser's version
 * @property {number} [minVersion] - current browser's minimum supported version
 * @property {boolean} compatible - is current browser supported ?
 */
const browser = Object.assign({
  compatible: !/\s/.test(adapter.browserDetails.browser)
    && (!adapter.browserDetails.minVersion
      || adapter.browserDetails.version >= adapter.browserDetails.minVersion)
}, adapter.browserDetails);

const version = `Reach v${SDK_VERSION} | Schema ${SCHEMA_VERSION} | Webcom v${Webcom.SDK_VERSION}`; // eslint-disable-line no-undef
let message = '';
if (browser.version === null) {
  message = 'Unsupported browser: browser must support WebRTC Peer-to-peer connections to use Reach';
} else if (browser.minVersion && browser.minVersion > browser.version) {
  message = `Unsupported browser: browser is outdated, update to latest version (${browser.minVersion}+)`;
} else if (!adapter.browserShim) {
  message = 'No shim for your browser. There might a problem with your package.';
}

// Log browser status & SDKs versions on load
let args = [`${version} ${message}`];
if (/^(chrome|firefox)$/.test(browser.browser)) {
connection.setRemoteDescription(rtcSdp).then(function () {
                    //use in edge for ice
                    if (adapter.browserDetails.browser == "edge") {
                        // var sdpArray = sdp.split("\n");
                        // var i;
                        // for (i = 0; i < sdpArray.length; i++) {
                        //     if (sdpArray[i].indexOf("m=video") == 0) {
                        //         break;
                        //     }
                        //     if (sdpArray[i].indexOf("a=candidate:1 1") == 0 || sdpArray[i].indexOf("a=candidate:2 1") == 0) {
                        //         var rtcIceCandidate = new RTCIceCandidate({
                        //             candidate: sdpArray[i],
                        //             sdpMid: "audio",
                        //             sdpMLineIndex: 0
                        //         });
                        //         connection.addIceCandidate(rtcIceCandidate);
                        //     }
                        // }
                        // var video = false;
MediaDevicesShim.getSharedScreen = function(constraints) {
  if (window.location.protocol !== 'https:') {
    return Promise.reject(new Error('Screen sharing only works on HTTPS, try the https:// version of this page'));
  }

  if ('chrome' == webrtc.browserDetails.browser) {
    return this._getSharedScreenChrome(constraints);
  } else if ('firefox' == webrtc.browserDetails.browser) {
    return this._getSharedScreenFirefox(constraints);
  }
};
module.exports = function (constraints, cb) {
    var hasConstraints = arguments.length === 2;
    var callback = hasConstraints ? cb : constraints;
    var error;

    if ('getDisplayMedia' in window.navigator.mediaDevices) { // prefer spec getDisplayMedia
        window.navigator.mediaDevices.getDisplayMedia(constraints)
        .then(function (stream) {
            callback(null, stream);
        }).catch(function (err) {
            callback(err);
        });
    } else if (adapter.browserDetails.browser === 'chrome') {
        if (sessionStorage.getScreenMediaJSExtensionId) {
            // check that the extension is installed by looking for a
            // sessionStorage variable that contains the extension id
            // this has to be set after installation unless the content
            // script does that
            chrome.runtime.sendMessage(sessionStorage.getScreenMediaJSExtensionId,
                {type:'getScreen', id: 1}, null,
                function (data) {
                    if (!data || data.sourceId === '') { // user canceled
                        var error = new Error('NavigatorUserMediaError');
                        error.name = 'NotAllowedError';
                        callback(error);
                    } else {
                        constraints = (hasConstraints && constraints) || {audio: false, video: {
                            mandatory: {
                                chromeMediaSource: 'desktop',
MediaDevicesShim._getSharedScreenChrome = function(constraints) {
  var chromever = webrtc.browserDetails.version;
  var maxver = 33;
  if (window.navigator.userAgent.match('Linux')) {
    maxver = 35;
  }	// "known" crash in chrome 34 and 35 on linux
  if (chromever >= 26 && chromever <= maxver) {
    // Chrome 26->33 requires some awkward chrome://flags manipulation
    constraints = Helpers.extend({}, constraints, {
      video: {
        mandatory: {
          googLeakyBucket: true,
          maxWidth: window.screen.width,
          maxHeight: window.screen.height,
          maxFrameRate: 3,
          chromeMediaSource: 'screen'
        }
      }
/*jslint indent:2,sloppy:true, node:true */

var adapter = require('webrtc-adapter');
var PromiseCompat = require('es6-promise').Promise;
var RTCPeerConnection = adapter.RTCPeerConnection;
var RTCSessionDescription = adapter.RTCSessionDescription;
var RTCIceCandidate = adapter.RTCIceCandidate;

var DataChannel = require('./core.rtcdatachannel');

var RTCPeerConnectionAdapter = function (cap, dispatchEvent, configuration) {
  this.dispatchEvent = dispatchEvent;
  try {
    this.connection = new RTCPeerConnection(configuration);
  } catch (e) {
    // Note: You can't ask the provider to close you synchronously, since
    // the constructor has not yet returned, so there's no 'this' that
    // the provider can know about yet.
    setTimeout(cap.provider.close.bind(cap.provider, this), 0);
    return;
  }

  this.events = [
/*jslint indent:2,sloppy:true, node:true */

var adapter = require('webrtc-adapter');
var PromiseCompat = require('es6-promise').Promise;
var RTCPeerConnection = adapter.RTCPeerConnection;
var RTCSessionDescription = adapter.RTCSessionDescription;
var RTCIceCandidate = adapter.RTCIceCandidate;

var DataChannel = require('./core.rtcdatachannel');

var RTCPeerConnectionAdapter = function (cap, dispatchEvent, configuration) {
  this.dispatchEvent = dispatchEvent;
  try {
    this.connection = new RTCPeerConnection(configuration);
  } catch (e) {
    // Note: You can't ask the provider to close you synchronously, since
    // the constructor has not yet returned, so there's no 'this' that
    // the provider can know about yet.
    setTimeout(cap.provider.close.bind(cap.provider, this), 0);
    return;
  }
/*jslint indent:2,sloppy:true, node:true */

var adapter = require('webrtc-adapter');
var PromiseCompat = require('es6-promise').Promise;
var RTCPeerConnection = adapter.RTCPeerConnection;
var RTCSessionDescription = adapter.RTCSessionDescription;
var RTCIceCandidate = adapter.RTCIceCandidate;

var DataChannel = require('./core.rtcdatachannel');

var RTCPeerConnectionAdapter = function (cap, dispatchEvent, configuration) {
  this.dispatchEvent = dispatchEvent;
  try {
    this.connection = new RTCPeerConnection(configuration);
  } catch (e) {
    // Note: You can't ask the provider to close you synchronously, since
    // the constructor has not yet returned, so there's no 'this' that
    // the provider can know about yet.
    setTimeout(cap.provider.close.bind(cap.provider, this), 0);
    return;
  }

Is your System Free of Underlying Vulnerabilities?
Find Out Now