iris-react-sdk
v2.0.2
Published
React version of 555 RTC JS SDK
Downloads
26
Readme
react-js-sdk
This document covers the 555 JavaScript SDK's React Component.
Getting started
$ npm install iris-react-sdk --save
Usage - Examples
import {RoomContainer, RtcSdk} from 'iris-react-sdk';
Make connection using
iristoken
androutingId
// Call connection method RtcSdk.connect(iristoken, routingId, config.urls.eventManager); //Listen to onConnected event RtcSdk.onConnected = () => { console.log("App :: onConnected :: Iris connection successful"); } //Listen to notification event RtcSdk.onNotification = (payload) => { console.log("App:: onNotification :: Payload : ", JSON.stringify(payload)); } //Listen to iris diconnected event RtcSdk.onDisconnected = () => { console.log("App:: onDisconnected"); } //Listen to connection errors RtcSdk.onError = (error) => { console.log("App:: onError :: error : ", error); }
Using
RoomContainer
to initiate/accept call
return (
<RoomContainer
ref="room"
Type={this.state.Type}
RoomId={this.state.RoomId}
Config={this.state.Config}
NotificationPayload={this.state.NotificationPayload}
onLocalStream={this.onLocalStream}
onRemoteStream={this.onRemoteStream}
onSessionCreated={this.onSessionCreated}
onSessionJoined={this.onSessionJoined}
onSessionConnected={this.onSessionConnected}
onSessionParticipantJoined={this.onSessionParticipantJoined}
onSessionParticipantAudioMuted={this.onSessionParticipantAudioMuted}
onSessionParticipantLeft={this.onSessionParticipantLeft}
onSessionEnd={this.onSessionEnd}
onUserProfileChange={this.onUserProfileChange}
onSessionSIPStatus={this.onSessionSIPStatus}
onError={this.onError}
onEvent={this.onEvent}
/>
)
...
let roomId = response.room_id;
let Config = {
irisToken: "",
routingId: "",
toTN: "",
fromTN: "",
toRoutingId: "",
traceId: "",
userData: "",
SessionType: 'outgoing',
notificationPayload: ''
};
this.setState({
RoomId:roomId,
Config:Config,
});
APIs
Connection APIs - Make a connection using connect
- Example
import RtcSdk from 'iris-react-sdk';
RtcSdk.connect(irisToken, routingId, serverUrl);
Params
serverUrl
{String}: The url to event manageririsToken
{String}: A valid IRIS tokenroutingId
{String}: Routing id of the user who is trying to login
Connection APIs - Disconnect using disconnect
- Example
import RtcSdk from 'iris-react-sdk';
RtcSdk.disconnect();
Params
- None
Media devices - Get a list of meida devices with getMediaDevices
Returns a promise with list of available audio and video devies
- Example
import RtcSdk from 'iris-react-sdk';
RtcSdk.getMediaDevices();
Request Media Device Permission - requestMediaPermission
Returns a promise with boolean whether permission is acquired or not
- Example
import RtcSdk from 'iris-react-sdk';
let deviceType = 'microphone'
RtcSdk.requestMediaPermission(deviceType).then((permissionAcquired){
if(permissionAcquired){
// Success
}else{
// Failed
}
});
PSTN APIs - Hold a PSTN call using pstnHold
- Example
this.refs.room.pstnHold(roomId, participantJid);
Params
roomId
{String} : Room IdparticipantJid
{String}: Remote participant routingId/resourceId
PSTN APIs - UnHold a PSTN call using pstnUnHold
- Example
this.refs.room.pstnUnHold(roomId, participantJid);
Params
roomId
{String} : Room IdparticipantJid
{String}: Remote participant routingId/resourceId
PSTN APIs - Merge two PSTN calls using pstnMerge
- Example
this.refs.room.pstnMerge(roomId, firstParticipantJid, secondParticipantJid);
Params
roomId
{String} : Room IdfirstParticipantJid
{String}: First remote participant's routingId/resourceIdsecondSession
{object}: IrisRtcSession object of the session to be mergedsecondParticipantJid
{String}: Second remote participant's routingId/resourceId
PSTN APIs - End PSTN call using pstnHangup
- Example
this.refs.room.pstnHangup(roomId, participantJid);
Params
roomId
{String} : Room IdparticipantJid
{String}: Remote participant's routingId/resourceId
Callbacks
Connection - For connection successful listen to onConnected
- Example
RtcSdk.onConnected = () => {
console.log("App :: onConnected :: Iris connection successful");
}
Params
- None
Connection - For Notification listen to onNotification
- Example
RtcSdk.onNotification = (notificationPayload) => {
console.log("App :: notificationPayload :: Iris notification received");
}
Params
notificationPayload
{json} : Notification payload with the information to join session
Session - For PSTN SIP Status listen to onSessionSIPStatus
- Example
onSessionSIPStatus = (roomId, participantJid, status) => {
console.log("App :: onSessionSIPStatus :: PSTN SIP Status : "+ status);
}
Params
roomId
{String} : RoomId of the sessionparticipantJid
{String} : Jid of the participantstatus
{String} : PSTN Status ex. initializing, connecting, ringing, connected.
RoomContainer - For local media stream onLocalStream
- Example
onLocalStream = (stream) => {
console.log("App :: onLocalStream :: Local media stream received");
}
Params
stream
{object} : Local media stream