README
Quantum SDK
Installation
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
Installation is done using thenpm install
command:
$ npm install convo-quantum-sdk
Import in ReactJS project:
import QuantumSdk from "convo-quantum-sdk";
Initializing QuantumSdk requires the mock server to e available for testing, check branch feature/PLT-74
Code for mock server is available here
Mock server is initialized by running command:
$ node index.js
Usage example:
import React from "react";
import "./App.css";
import QuantumSdk from "convo-quantum-sdk";
function App() {
return (
<div className="App">
<header className="App-header">
<video id="remoteVideo" autoPlay />
<video id="viVideo" autoPlay />
<button onClick={initSdk}>Init SDK</button>
</header>
</div>
);
}
export default App;
function initSdk() {
QuantumSdk.builder()
.withRemoteElementId("remoteVideo")
.withViElementId("viVideo")
.withPhoneNumber("2402066101")
.withOnCalling(() => {
alert("withOnCalling");
})
.withOnRinging(() => {
alert("withOnRinging");
})
.withOnAccepted(() => {
alert("withOnAccepted");
})
.withOnIncomingCall((callerNumber) => {
alert("Incoming Call from: " + callerNumber);
})
.withOnHangUp(() => {
alert("withOnHangUp");
})
.initSdk();
}
Enumarate devices & selecting specific device
/**
* Returns an array of MediaDevices available
* @param {QuantumSdk.MediaDeviceKind} kind
*/
async function enumerateDevices(kind) {
let devices = kind
? await QuantumSdk.enumerateDevices(kind)
: await QuantumSdk.enumerateDevices();
console.log(devices);
}
Yuo can reuse deviceId parameter from enumerateDevices() for selecting a specific device:
async function setVideoDevice() {
const videoDevices = await QuantumSdk.enumerateDevices(
QuantumSdk.MediaDeviceKind.VIDEOINPUT
);
const deviceId = videoDevices[0]["deviceId"];
QuantumSdk.setVideoSource(deviceId);
}
async function setAudioInput() {
const audioDevices = await QuantumSdk.enumerateDevices(
QuantumSdk.MediaDeviceKind.AUDIOINPUT
);
const deviceId = audioDevices[0]["deviceId"];
QuantumSdk.setAudioSource(deviceId);
}
async function setAudioOutput() {
const audioDevices = await QuantumSdk.enumerateDevices(
QuantumSdk.MediaDeviceKind.AUDIOOUTPUT
);
const deviceId = audioDevices[0]["deviceId"];
QuantumSdk.setAudioSink(deviceId);
}
Make call and hang up
function makeCall(callConfiguration = {phoneNumber}) {
QuantumSdk.makeCall(callConfiguration);
}
function answerCall() {
QuantumSdk.answerCall();
}
function declineCall() {
QuantumSdk.declineCall();
}
function hangUp() {
QuantumSdk.hangUp();
}
Toggling media while in call
function toggleVideo() {
QuantumSdk.toggleVideo();
}
function toggleMic() {
QuantumSdk.toggleMic();
}