Options
All
  • Public
  • Public/Protected
  • All
Menu

Luware RTCLauncher SDK Documentation 2.0.3141

RTCLauncher SDK

Installation

  • To use RTCLauncher SDK on your site:

    Add link to RTCLauncher SDK .js file to the page

    <script src="{path to scripts folder}/luware.rtclauncher.sdk.js">

  • The following steps should be done to use RTCLauncher SDK in compressioned state with IIS on your site:
    • Add link to RTCLauncher SDK .js.gz file to the page

    • <script src="{path to scripts folder}/luware.rtclauncher.sdk.js.gz">

    • Assign custom header 'Content-encoding: gzip' to response for rtclauncher.sdk.js.gz

    • Add to global config system.webServer > staticContent

    • <mimeMap fileExtension=".js.gz" mimeType="application/javascript" />

    • IIS Compression can be disabled

    • <urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />

Usage

  1. Initialize library

  2. Use your tenantId

    rtclauncher.init("https://{link to RTCLauncher API}", {tenantId}, "https://{link to Client url}", {createTask}, {link to Pexip}, {Signalr transport protocols});

  3. Define SiteContact or SiteGroup (take tenantId, siteId, contactId from RTCLauncher Admin)

  4. var siteContact = {
        tenantId: "795cea582a97e911911108dce072696b",
        siteId: "aea8de86-2a97-e911-9111-08dce072696b",
        contactId: "2f1ead91-2a97-e911-9111-08dce072696b"
    };
    var siteGroup = {
        tenantId: "795cea582a97e911911108dce072696b",
        siteId: "6f6b8710-a291-e911-90fc-08dce072695b",
        groupId: "44543e4f-3994-e911-90fc-08dce072695b"
    };

  5. Get contact or group details

  6. rtclauncher.getContact(siteContact).then(function (contact) {}); 

    rtclauncher.getGroup(siteGroup).then(function (group) {}); 

  7. Start modality (more info can be found in Samples of usage section)

Samples of usage

Presence

Subscribe to presence changes

rtclauncher.contactPresenceChanged.on(siteContact, function (presence) {
    console.log(presence);
});

rtclauncher.groupPresenceChanged.on(siteGroup, function (presence) {
    console.log(presence);
});

Connection

Subscribe to changes in connection to API

rtclauncher.serviceConnectionLost.on(function () {}); 

rtclauncher.serviceConnectionRecovered.on(function () {}); 

Restoring conversation

Call rtclauncher.pauseConversation() before window.onunload event or after service connection was lost to restore conversation after page reload.

 rtclauncher.serviceConnectionLost.on(function (){
     rtclauncher.pauseConverastion();
})

Conversation automatically will be shared between different tabs with one sub-domains. Conversation subscriptions will be fired in all tabs in the following way: Chat will be active in all tabs while Audio and Video calls, Co-browsing and presentation could be active only in one tab in a moment.


Audio & Video calls

Subscribe to audio call events

function setupAudio(data) {
    //get audio html element
    var container = document.querySelector('#audio');
    if (data.audioStream) {
        try {             container.srcObject = data.audioStream;
        } catch (error) {
            container.src = URL.createObjectURL(data.audioStream);         }
    } else {
        //for safari
        container.src = data.audioUrl;
    }
}

function onStopAudio() {
    //get audio html element
    var container = document.querySelector('#audio');
    //clean audio html element
    container.srcObject = null;     container.src = "";
}

function onIncomingAudio(event) {}

function onAudioTransfer(event) {}

rtclauncher.conversation.audioChanged.on(setupAudio, onStopAudio, onIncomingAudio, onAudioTransfer);

Start and stop audio call

rtclauncher.startAudio(siteContact).catch(function (error) {
    console.log(error);
});

rtclauncher.stopAudio(siteContact).catch(function (error) {
    console.log(error)
});

Accept and decline audio call

var mediaDevices = {
    //can be taken from webRTC
    audioDeviceId: "37f1b39e242983a8b8be1ad96cf953b0e49d91f0ce536140b5ba0c410792e7f1"
}
rtclauncher.acceptAudio(siteContact, mediaDevices);

rtclauncher.declineVideo(siteContact);

Subscribe to video call events

function setupVideo(data) {
    var container = document.querySelector('#video');
    var selfContainer = document.querySelector('#selfVideo');
    if (data.videoUrl) {
        if (typeof (data.videoUrl) == "string") {
            container.src = data.videoUrl;         } else {
            try {
                container.srcObject = data.videoUrl;             } catch (error) {
                container.src = URL.createObjectURL(data.videoUrl);
            }
        }     } else {
        try {
            setTimeout(function () {                 container.srcObject = data.videoStream;
                container.play();             }, 700);
        } catch (error) {
            container.src = URL.createObjectURL(data.videoStream);
        }
    }
    if (data.selfVideoStream) {
        try {
            setTimeout(function () {                 selfContainer.srcObject = data.selfVideoStream;
                selfContainer.play();             }, 700);
        } catch (error) {
            selfContainer.src = URL.createObjectURL(data.selfVideoStream);         }
    } else {
        selfContainer.src = data.selfVideoUrl;
    }
}

function onStopVideo() {
    var container = document.querySelector('#video');
    container.srcObject = null;
    container.src = "";

    var selfContainer = document.querySelector('#selfVideo');
    selfContainer.srcObject = null;selfContainer.src = "";
}

function onIncomingVideo(event) {}

function onVideoTransfer(event) {}

rtclauncher.conversation.videoChanged.on(setupVideo, onStopVideo, onIncomingVideo, onVideoTransfer);

Start and stop video call

var mediaDevices = {
    //can be taken from webRTC
    videoDeviceId: "dcc3c1951e4b7e945761f7a91ad128298c7f853c58cb2f0304639d2a3589a647",     audioDeviceId: "37f1b39e242983a8b8be1ad96cf953b0e49d91f0ce536140b5ba0c410792e7f1"
}

var userDetails = {
     userName: "SDK user";
    disclaimer: true;
}
rtclauncher.startVideo(siteContact, mediaDevices, userDetails).catch(function (error) {
    console.log(error);
});

rtclauncher.stopVideo(siteContact).catch(function (error) {
    console.log(error)
});

Accept and decline video call

var mediaDevices = {
    //can be taken from webRTC
    videoDeviceId: "dcc3c1951e4b7e945761f7a91ad128298c7f853c58cb2f0304639d2a3589a647",     audioDeviceId: "37f1b39e242983a8b8be1ad96cf953b0e49d91f0ce536140b5ba0c410792e7f1"
}
rtclauncher.acceptVideo(siteContact, mediaDevices);

rtclauncher.declineVideo(siteContact);

Mute/unmute audio

rtclauncher.toggleMuteAudio(siteContact, true);

Subscribe to activating call in the other tab

function onCallUpdated(isActive) {}

rtclauncher.conversation.callUpdated.on(onCallUpdated);

Update media devices which are used for call

rtclauncher.updateMediaDevices(siteContact, mediaDevices);

Send DTMF

rtclauncher.sendDTMF(siteContact, 3);

Start and stop direct video or audio call.

RTCLauncher must be inited with pexip url. Target parameter should contain conference prefix and conferenceId. Example: "pstnId:12345678".

rtclauncher.startVideoDirectly(target, userDetails, mediaDevices).catch(function(error){
    console.log(error);
  });
rtclauncher.stopDirectCall().catch(function(error){
    console.log(error);
  });

Chat

Start chat, send message and typing event

var userDetails = {
     userName: "SDK user";
}
//returns id of sent message
rtclauncher.sendMessage(siteContact, "Hello!", userDetails);

'Typing' event has to be sent each 3 seconds while user is typing:

rtclauncher.sendTyping(siteContact);

Subscribe to chat events

function onStartChat () {}

function onStopChat () {}

rtclauncher.conversation.chatChanged.on(onStartChat, onStopChat);

rtclauncher.conversation.messageReceived.on(function (message) {});

rtclauncher.conversation.messageStatusReceived.on(function (messageStatus) {
    // status of message by id (received by 'sendMessage' method)
});

rtclauncher.conversation.typingParticipantAdded.on(function (participant) {
    // sip of currently typing participant
    // more information about participant can be received by 'participantAdded' event subscription
});

rtclauncher.conversation.typingParticipantRemoved.on(function (participant) {
    // sip of participant who stopped typing
    // more information about participant can be received by 'participantAdded' event subscription
});

Participants

Subscribe to conversation participants changes

rtclauncher.conversation.participantAdded.on(function (participant) {});

rtclauncher.conversation.participantRemoved.on(function (participant) {});

Cobrowsing

Subscribe to cobrowsing events

function onStartCobrowsing () {}

function onStopCobrowsing () {}

Subscribe to activating cobrowsing in the other tab

function onActiveOtherTabCobrowsing (isActive) {}

rtclauncher.conversation.cobrowsingChanged.on(onStartCobrowsing, onStopCobrowsing, onActiveOtherTabCobrowsing);

Start and stop cobrowsing

rtclauncher.startCobrowsing(siteContact).catch(function (error) {
    console.log(error);
});

rtclauncher.stopCobrowsing(siteContact).catch(function (error) {
    console.log(error);
});

Start and stop cobrowsing for the different window

To start cobrowsing in a window other than the original one, add additional parameters to the startCobrowsing method: the window instance and the origin of the window where cobrowsing should start

  1. Place luware.rtclauncher.cobrowsing.js file in iframe where cobrowsing should start.
  2. Init cobrowsing with widget key and surfly Url:
     cobrowsing.init({
        widget_key: "b0f384c875664ce7befb82ec99241c0a",
         surflyUrl: "https://cobrowsing.luware.com/surfly.js"
       })
    Error COBROWSING_INIT_ERROR will be throwing in case calling cobrowsing.setWindow without init.
  3. RTCLauncher SDK in a parent window
    1. Initialize cobrowsing script with window instance and origin of window where RTCLauncher sdk is placed:

      if(window.parent){
          cobrowsing.setWindow(window.parent, "https://rtclauncher.dev.luware.com");
      }

    2. Start cobrowsing for child iframe.

      Add additional parameters to startCobrowsing method: window instance and origin of the window (iframe) where cobrowsing should start.

      rtclauncher.startCobrowsing(siteContact, window.frames.appIframe, "https://rtclauncher.luware.com").catch(function (error){
          console.log(error);
      });

    3. Stop cobrowsing

      rtclauncher.stopCobrowsing(siteContact).catch(function (error) {
          console.log(error);
      });
  4. RTCLauncher SDK in sibling iframe
    1. Initialize cobrowsing script with window instance and origin of window (iframe) where RTCLauncher sdk is placed:

      if (window.parent.frames) {
          cobrowsing.setWindow(window.parent.frames.sdkIframe, "https://rtclauncher.dev.luware.com");
      }

    2. Start cobrowsing for sibling iframe.

      Add additional parameters to startCobrowsing method: window instance and origin of the window (iframe) where cobrowsing should start.

      rtclauncher.startCobrowsing(siteContact, window.parent.frames.appIframe, "https://rtclauncher.luware.com").catch(function (error) {
          console.log(error);
      });

    3. Stop cobrowsing

      rtclauncher.stopCobrowsing(siteContact).catch(function (error) {
          console.log(error);
      });
  5. RTCLauncher SDK in a child window
    1. Subscribe on escalated event in main window and Initialize cobrowsing script with window instance and origin of escalated window is placed:

      function onEscalated() {
          if (escalatedWindow) {
              cobrowsing.setWindow(escalatedWindow, "https://rtclauncher.dev.luware.com");
          }

      rtclauncher.conversation.esclated.on(onEscalated)

    2. Call escalate with url where its html is placed and save returned window

      rtclauncher.escalate("https://rtclauncher.dev.luware.com/testapp/conversation.html").then(function(result) { 
              escalatedWindow = result;
          });

    3. Call startCobrowsing in escalated window with additional parameters: parent window and parent origin

       rtclauncher.startCobrowsing(siteContact, window.opener, "https://rtclauncher.dev.luware.com")

Presentation

Subscribe to incoming presentation call events. Modality supported only for Audio and Video calls.

function onStartPresentation(stream) {
    var container = document.querySelector('#presentation');
    if (stream.id) {         container.srcObject = stream;
    } else {
        container.src = stream;
    }
}

function onStopPresentation() {
    var container = document.querySelector('#presentation');
    container.srcObject = null;
    container.src = "";
}

Subscribe to activating presentation in other tab

function onActiveOtherTabPresentation (isActive) {}

rtclauncher.conversation.presentationChanged.on(onStartPresentation, onStopPresentation, onActiveOtherTabPresentation);

Direct Conference

Subscribe to events from conference.

rtclauncher.conference.subscribe(id);
rtclauncher.conference.lobbyParticipantAdded.on(onlobbyParticipantAdded);
rtclauncher.conference.lobbyParticipantRemoved.on(onlobbyParticipantRemoved);
rtclauncher.conference.conferenceParticipantAdded.on(onConferenceParticipantAdded);
rtclauncher.conference.conferenceParticipantRemoved.on(onConferenceParticipantRemoved);
rtclauncher.conference.participantModalityAdded.on(onParticipantModalityAdded);
rtclauncher.conference.participantModalityRemoved.on(onParticipantModalityRemoved);
rtclauncher.conference.messageReceived.on(onMessageReceived);

Unsubscribe to events from conference.

rtclauncher.conference.unsubscribe(id);
rtclauncher.conference.lobbyParticipantAdded.off(onlobbyParticipantAdded);
rtclauncher.conference.lobbyParticipantRemoved.off(onlobbyParticipantRemoved);
rtclauncher.conference.conferenceParticipantAdded.off(onConferenceParticipantAdded);
rtclauncher.conference.conferenceParticipantRemoved.off(onConferenceParticipantRemoved);
rtclauncher.conference.participantModalityAdded.off(onParticipantModalityAdded);
rtclauncher.conference.participantModalityRemoved.off(onParticipantModalityRemoved);
rtclauncher.conference.messageReceived.off(onMessageReceived);

Start Audio

rtclauncher.conference.audioChanged.on(setupAudio, onStopAudio);
rtclauncher.conference.getConferenceTarget(id).then(function (target) {
                    rtclauncher.conference.startAudio(target); });

Start video

rtclauncher.conference.videoChanged.on(setupVideo, onStopVideo);
rtclauncher.conference.getConferenceTarget(id).then(function (target) {
                    rtclauncher.conference.startVideo(target, mainSpikerOnly); });

Subscribe to presentation events

rtclauncher.conference.presentationChanged.on(setupPresentation, onStopPresentation);

Unsubscribe to presentation events

rtclauncher.conference.presentationChanged.off(setupPresentation, onStopPresentation);

Send messages (only after audio/video is established)

rtclauncher.conference.sendMessage(message);

Generated using TypeDoc