Code Monkey home page Code Monkey logo

apirtc-lwc-salesforce's Introduction

ApiRTC-LWC-Salesforce

Integration of apiRTC in Salesforce Lightning Web Components (LWC)

This sample demonstrate how to integrate apiRTC in a LWC and use it in your Salesforce environment.

This enables you to use WebRTC to communicate from your Salesforce organisation to a Web application by using apiRTC platform.

We demonstrate the possibility to :

  • Join a conversation.
  • Publish your stream : audio only, video only, audio and video, in this conversation.
  • Share your screen in this conversation.
  • Record the conversation and access to the associated media files

Other apiRTC feature can also be implemented based on this tutorial.

Our sample is based on the "Hello World" Lightning Web Component creation in a scratch orgs documentation that you can find here.

You can use this reference to understand how to start your Salesforce development environment until the "Create a Lightning Web Component" step.

Then you will then find here the different necessary steps to start and allow apiRTC to run in Salesforce and use our LWC code sample.

Steps to allow apiRTC to run in your Salesforce environment

Load apiRTC as a static ressource

You will need to download apiRTC on our CDN (Use "Save as")

NOTE: Make sure to download this apiRTC version : apiRTC-with-sio as we did some adaptations to be able to run in Salesforce environment.

Then search for "static" in Salesforce to add apiRTC :

Load the apiRTC file as "apirtcsio" : this name is used in the source code for import :

import apiCC from "@salesforce/resourceUrl/apirtcsio";

Load apiRTC as a static ressource!

Load apiRTC as a static ressource!

Add necessary apiRTC server URLs as CSP Trusted site

We need to add three URLs in the configuration:

  • *.apizee.com : for access to our dashboard
  • https://ccs6.apizee.com for https access to our Call Control Server
  • wss://ccs6.apizee.com for wss access to our Call Control Server

Search for "trusted" in salesforce and apply the following configuration :

apiRTC trusted sites!

Make sure that Lightning Web Security is activated

Lightning Web security is required to enable a correct access to WebRTC features

Lightning Web Security!

You are ready to load our LWC sample code in your Salesforce environement

Get the code with :

git clone https://github.com/ApiRTC/ApiRTC-LWC-Salesforce.git

Use our component source code in the force-app/main/default/lwc folder instead of "Create Lightning web components" step in documentation.

You can then continue with Salesforce documentation steps.

  • Push Source to the Scratch Org
  • Open the Scratch Org
  • Add the Component to a Lightning Page

Start an apiRTC conversation

Our sample use our demo apiKey : myDemoApiKey

this.ua = new this.apiRTC.UserAgent({

    //==============================
    // TODO Change with your apiKey
    //==============================
    uri: 'apzkey:myDemoApiKey'
});

With this apiKey, you can use our conferencing tutorial for a first try.

Create your own count here

Some apiRTC restrictions in Salesforce environment

Some apiRTC feature are not available in Salesforce due to LWC restrictions. Check locker API viewer for more information.

  • Background subtraction : blur, background image - applyVideoProcessor() is not available in LWC

Worker is not supported in LWC

  • Audio filters : noiseReduction - ApplyAudioProcessor() is not available in LWC

Worklet / AudioWorklet / AudioWorkletNode are not supported in LWC

Some development information

As you will see in our source code sample usage of loadScript() is mandatory to load library in LWC :

You can find informations about it on Platform Resource Loader and Use Third-Party JavaScript Libraries

loadScript(this, apiCC).then(() => {

    this.apiRTCisLoaded = true;
    this.apiRTC = window.apiRTC;
    console.debug('apiRTC version :', apiRTC.version);
    let apiRTCInfoElt = this.template.querySelector(".apiRTCInfo");
    apiRTCInfoElt.replaceWith('You are using apiRTC version : ' + apiRTC.version);
    this.apiRTC.setLogLevel(10);

}).catch(err => {
    console.error('Error when loading ApiRTC :', err)
});

apirtc-lwc-salesforce's People

Contributors

fredluart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.