Add link to RTCLauncher SDK .js file to the page
<script src="{path to scripts folder}/luware.rtclauncher.sdk.js">
<script src="{path to scripts folder}/luware.rtclauncher.sdk.js.gz">
<mimeMap fileExtension=".js.gz" mimeType="application/javascript" />
<urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
Use your tenantId
rtclauncher.init("https://{link to RTCLauncher API}", {tenantId}, "https://{link to Client url}", {createTask}, {link to Pexip}, {Signalr transport protocols});
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"
};
rtclauncher.getContact(siteContact).then(function (contact) {});
rtclauncher.getGroup(siteGroup).then(function (group) {});
Subscribe to presence changes
rtclauncher.contactPresenceChanged.on(siteContact, function (presence) {
console.log(presence);
});
rtclauncher.groupPresenceChanged.on(siteGroup, function (presence) {
console.log(presence);
});
Subscribe to changes in connection to API
rtclauncher.serviceConnectionLost.on(function () {});
rtclauncher.serviceConnectionRecovered.on(function () {});
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.
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);
});
Start chat, send message and typing event
var userDetails = {
userName: "SDK user";
}
//returns id of sent message
rtclauncher.sendMessage(siteContact, "Hello!", userDetails);
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
});
Subscribe to conversation participants changes
rtclauncher.conversation.participantAdded.on(function (participant) {});
rtclauncher.conversation.participantRemoved.on(function (participant) {});
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
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.
if(window.parent){
cobrowsing.setWindow(window.parent, "https://rtclauncher.dev.luware.com");
}
rtclauncher.startCobrowsing(siteContact, window.frames.appIframe, "https://rtclauncher.luware.com").catch(function (error){
console.log(error);
});
rtclauncher.stopCobrowsing(siteContact).catch(function (error) {
console.log(error);
});
if (window.parent.frames) {
cobrowsing.setWindow(window.parent.frames.sdkIframe, "https://rtclauncher.dev.luware.com");
}
rtclauncher.startCobrowsing(siteContact, window.parent.frames.appIframe, "https://rtclauncher.luware.com").catch(function (error) {
console.log(error);
});
rtclauncher.stopCobrowsing(siteContact).catch(function (error) {
console.log(error);
});
function onEscalated() {
if (escalatedWindow) {
cobrowsing.setWindow(escalatedWindow, "https://rtclauncher.dev.luware.com");
}
rtclauncher.conversation.esclated.on(onEscalated)
rtclauncher.escalate("https://rtclauncher.dev.luware.com/testapp/conversation.html").then(function(result) {
escalatedWindow = result;
});
rtclauncher.startCobrowsing(siteContact, window.opener, "https://rtclauncher.dev.luware.com")
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);
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