iris-react-js
This document covers the Iris JavaScript SDK's React Component.
Getting started
$ npm install iris-react-sdk --save
Usage - Examples
import {IrisRoomContainer, IrisRtcSdk} from 'iris-react-sdk';
-
Make connection using
iristoken
androutingId
// Call connection method IrisRtcSdk.connect(iristoken, routingId, config.urls.eventManager); //Listen to onConnected event IrisRtcSdk.onConnected = () => { console.log("App :: onConnected :: Iris connection successful"); } //Listen to notification event IrisRtcSdk.onNotification = (payload) => { console.log("App:: onNotification :: Payload : ", JSON.stringify(payload)); } //Listen to iris diconnected event IrisRtcSdk.onDisconnected = () => { console.log("App:: onDisconnected"); } //Listen to connection errors IrisRtcSdk.onError = (error) => { console.log("App:: onError :: error : ", error); }
-
Using
IrisRoomContainer
to initiate/accept call
return (
<IrisRoomContainer
ref="room"
Type={this.state.Type}
RoomId={this.state.RoomId}
Config={this.state.Config}
NotificationPayload={this.state.NotificationPayload}
onLocalStream={this.onLocalStream}
onRemoteStream={this.onRemoteStream}
onChatMessage={this.onChatMessage}
onChatAck={this.onChatAck}
onChatState={this.onChatState}
onEventHistory={this.onEventHistory}
onSessionCreated={this.onSessionCreated}
onSessionJoined={this.onSessionJoined}
onSessionConnected={this.onSessionConnected}
onSessionParticipantJoined={this.onSessionParticipantJoined}
onDominantSpeakerChanged={this.onDominantSpeakerChanged}
onSessionTypeChange={this.onSessionTypeChange}
onSessionParticipantVideoMuted={this.onSessionParticipantVideoMuted}
onSessionParticipantAudioMuted={this.onSessionParticipantAudioMuted}
onSessionParticipantNotResponding={this.onSessionParticipantNotResponding}
onSessionParticipantLeft={this.onSessionParticipantLeft}
onSessionEnd={this.onSessionEnd}
onUserProfileChange={this.onUserProfileChange}
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
connect
Connection APIs - Make a connection using - Example
import IrisRtcSdk from 'iris-react-sdk';
IrisRtcSdk.connect(irisToken, routingId, serverUrl);
-
Params
-
serverUrl
{String}: The url to event manager -
irisToken
{String}: A valid IRIS token -
routingId
{String}: Routing id of the user who is trying to login
-
disconnect
Connection APIs - Disconnect using - Example
import IrisRtcSdk from 'iris-react-sdk';
IrisRtcSdk.disconnect();
-
Params
- None
getMediaDevices
Media devices - Get a list of meida devices with Returns a promise with list of available audio and video devies
- Example
import IrisRtcSdk from 'iris-react-sdk';
IrisRtcSdk.getMediaDevices();
-
Params
- None
sendChatMessage
Message APIs - send message using - Example
this.refs.room.sendChatMessage(roomId, id, message);
-
Params
-
id
{String}: Unique UUID for the message -
message
{String}: Text message to be sent to participant
-
sendChatState
Message APIs - send chat state using - Example
this.refs.room.sendChatState(roomId, chatState);
-
Params
-
roomId
{String} : Room Id -
chatState
{String}: Chat States likeactive
,composing
,paused
,inactive
andgone
-
syncMessages
Message APIs - get messages history This returns a callback onEventHistory on IrisRoomContainer component.
- Example
this.refs.room.syncMessages();
-
Params
- None
startScreenshare
Screen Share API - Start screen share with This API starts sharing the screen. It should be called with screenShareConfig
- Example
var constraints = {
audio : false,
video : {
mandatory: {
chromeMediaSource: "desktop",
chromeMediaSourceId: response.streamId, // streamId from chrome extension response
maxWidth: window.screen.width,
maxHeight: window.screen.height,
maxFrameRate: 3
},
optional: []
}
}
var screenShareConfig = {
"constraints": constraints,
"screenShare": true
}
this.refs.room.startScreenshare(screenShareConfig);
-
Params
-
screenShareConfig
{json}: Stream config for screen share
-
endScreenshare
Screen Share API - End screen share with This API ends sharing the screen. It should be called with streamConfig
to get revert back to localStream
- Example
var streamConfig = {
"streamType": "video",
"resolution": ""
"constraints": "",
"screenShare": false
};
this.refs.room.endScreenshare(streamConfig);
-
Params
-
streamConfig
{json}: Stream config to revert back from screen to local stream
-
pstnHold
PSTN APIs - Hold a PSTN call using - Example
this.refs.room.pstnHold(roomId, participantJid);
-
Params
-
roomId
{String} : Room Id -
participantJid
{String}: Remote participant routingId/resourceId
-
pstnUnHold
PSTN APIs - UnHold a PSTN call using - Example
this.refs.room.pstnUnHold(roomId, participantJid);
-
Params
-
roomId
{String} : Room Id -
participantJid
{String}: Remote participant routingId/resourceId
-
pstnMerge
PSTN APIs - Merge two PSTN calls using - Example
this.refs.room.pstnMerge(roomId, firstParticipantJid, secondParticipantJid);
-
Params
-
roomId
{String} : Room Id -
firstParticipantJid
{String}: First remote participant's routingId/resourceId -
secondSession
{object}: IrisRtcSession object of the session to be merged -
secondParticipantJid
{String}: Second remote participant's routingId/resourceId
-
pstnHangup
PSTN APIs - End PSTN call using - Example
this.refs.room.pstnHangup(roomId, participantJid);
-
Params
-
roomId
{String} : Room Id -
participantJid
{String}: Remote participant's routingId/resourceId
-
restartSession
Session APIs - Restart a session This API ends the ongoing session and creates a new session
- Example
this.refs.room.restartSession(roomId);
-
Params
-
roomId
{String} : Room Id
-
muteParticipantAudio
Session APIs - Mute Participant Audio - Example
this.refs.room.muteParticipantAudio(roomId, participantJid, mute);
-
Params
-
roomId
{String} : Room Id -
participantJid
{String}: Remote participant's routingId/resourceId -
mute
{boolean}: Mute value true or false
-
muteParticipantVideo
Session APIs - Mute Participant Video - Example
this.refs.room.muteParticipantAudio(roomId, participantJid, mute);
-
Params
-
roomId
{String} : Room Id -
participantJid
{String}: Remote participant's routingId/resourceId -
mute
{boolean}: Mute value true or false
-
Callbacks
onConnected
Connection - For connection successful listen to - Example
IrisRtcSdk.onConnected = () => {
console.log("App :: onConnected :: Iris connection successful");
}
-
Params
- None
onNotification
Connection - For Notification listen to - Example
IrisRtcSdk.onNotification = (notificationPayload) => {
console.log("App :: notificationPayload :: Iris notification received");
}
-
Params
-
notificationPayload
{json} : Notification payload with the information to join session
-
onLocalStream
IrisRoomContainer - For local media stream - Example
onLocalStream = (stream) => {
console.log("App :: onLocalStream :: Local media stream received");
}
-
Params
-
stream
{object} : Local media stream
-