-
Notifications
You must be signed in to change notification settings - Fork 0
InfobipRTC
callApplication(callsConfigurationId: string, options?: ApplicationCallOptions): ApplicationCall
callWebrtc(identity: string, options?: WebrtcCallOptions): WebrtcCall
callPhone(phoneNumber: string, phoneCallptions?: PhoneCallOptions): PhoneCall
callViber(phoneNumber: string, from: string, viberCallptions?: ViberCallOptions): ViberCall
getAudioInputDevices(): Promise<MediaDeviceInfo[]>
getAudioOutputDevices(): Promise<MediaDeviceInfo[]>
getVideoInputDevices(): Promise<MediaDeviceInfo[]>
setAudioInputDevice(deviceId: string)
setVideoInputDevice(deviceId: string)
unsetAudioInputDevice(deviceId: string)
unsetVideoInputDevice(deviceId: string)
There are two types of events in Infobip RTC API:
-
RTC events
- Ones that are configured globally, per connection basis. Allowed values are:connected
,disconnected
,reconnecting
,reconnected
,incoming-application-call
, andincoming-webrtc-call
. -
Calls API events
- Ones that are configured per call basis. Allowed values are:ringing
,early-media
,established
,hangup
,error
,camera-video-added
,camera-video-updated
,camera-video-removed
screen-share-added
,screen-share-removed
,room-joined
,room-left
,conference-joined
,conference-left
,participant-joining
,participant-joined
,participant-muted
,participant-unmuted
,participant-deaf
,participant-undeaf
,participant-started-talking
,participant-stopped-talking
,participant-left
,participant-camera-video-added
,participant-camera-video-removed
,participant-screen-share-added
,participant-screen-share-removed
,remote-muted
,remote-unmuted
,remote-camera-video-added
,remote-camera-video-removed
,remote-screen-share-added
,remote-screen-share-removed
,network-quality-changed
,remote-network-quality-changed
.
For details about which type of call can receive which types of events, please consult their respective reference documentation.
Connects to Infobip's WebSocket API (WebRTC platform), using authentication and options supplied through the
constructor. If any temporary errors occur (e.g. network issue), the connection will be reattempted with an exponential
backoff with an initial delay of 50 ms, up to 1000 ms, over 50 attempts. In case the retries fail, or a permanent error
occurs (e.g. authentication error), an error is thrown. Also throws in case the status isn't OFFLINE
.
none
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
Disconnects from Infobip's WebSocket API (WebRTC platform), if connected. Throws an error if status is not ONLINE
.
none
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.disconnect();
Returns information about the currently connected user.
none
-
User
- Instance of theUser
object
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let user = infobipRTC.connectedUser();
Configures the event handler for RTC events, ones that are configured globally, per connection basis.
-
eventName
:string
- Name of the RTC event. Name of RTC event. Allowed values are:connected
,disconnected
,reconnecting
,reconnected
,incoming-application-call
andincoming-webrtc-call
. -
eventHandler
:any
- Function that will be called when specified event occurs, with exactly one parameter being passed to the function containing event information. Depending on the event, the passed parameter will contain a set of fields that will describe the event, namely:-
connected
-identity
field (identity set by Infobip client's app, when generating token via Infobip's HTTP /webrtc/1/token endpoint) will be provided.event = { identity: 'alice' }
-
disconnected
-reason
field will be provided, describing the reason why Infobip's WebSocket got disconnected.event = { reason: 'Connection error.' }
-
reconnecting
- No additional fields will be passed.event = {}
-
reconnected
- No additional fields will be passed.event = {}
-
incoming-application-call
- Incoming application call event (instance ofIncomingApplicationCallEvent
class), containing incoming application call ( instance ofIncomingApplicationCall
class) and custom data, will be provided.event = { incomingCall: IncomingApplicationCall, customData: CustomData }
-
incoming-webrtc-call
- Incoming WebRTC call event (instance ofIncomingWebrtcCallEvent
class), containing incoming WebRTC call (instance ofIncomingWebrtcCall
class) and custom data, will be provided.event = { incomingCall: IncomingWebrtcCall, customData: CustomData }
-
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.on('connected', function (event) {
console.log(`Connected with identity: ${event.identity}`);
});
infobipRTC.on('incoming-webrtc-call', function (event) {
console.log(`Incoming call from: ${event.incomingCall.source().identifier}`);
});
Makes an outgoing application call through Infobip's Calls platform to your application.
-
callsConfigurationId
:string
- Represents theCalls Configuration ID
, which is configured using theCalls Configuration API
. -
options
:ApplicationCallOptions
- Optional additional options used to configure an application call.
-
ApplicationCall
- Instance of theApplicationCall
.
- Example of initiating audio call:
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setAudio(true).build());
- Example of initiating video call:
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let applicationCall = infobipRTC.callApplication('45g2gql9ay4a2blu55uk1628', ApplicationCallOptions.builder().setVideo(true).build());
- Example of initiating a call towards Infobip Conversations:
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let applicationCall = infobipRTC.callApplication(InfobipCallsConfiguration.CONVERSATIONS, ApplicationCallOptions.builder().setAudio(true).build());
Makes an outgoing WebRTC call through Infobip's Calls platform to another WebRTC identity.
-
identity
:string
- Destination identity to call. If the identity does not exist, the call will be hung up with the proper reason. -
options
:WebrtcCallOptions
- Optional additional options used to configure a WebRTC applications call.
-
WebrtcCall
- Instance of theWebrtcCall
.
- Example of initiating audio call:
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let webrtcCall = infobipRTC.callWebrtc('Alice');
- Example of initiating video call:
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let webrtcCall = infobipRTC.callWebrtc('Bob', WebrtcCallOptions.builder().setVideo(true).build());
Makes an outgoing call to a given phone number (physical device, connected to Public Switched Telephone Network, mobile or landline).
-
phoneNumber
:string
- Destination phone number to call. If the phone number does not exist, the call will be hung up with the proper reason. -
phoneCallOptions
:PhoneCallOptions
- Optional additional options used to configure the phone call.
-
PhoneCall
- Instance of thePhoneCall
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let phoneCall = infobipRTC.callPhone('41793026727', PhoneCallOptions.builder().setFrom('33712345678').build());
Makes an outgoing call to a Viber application associated with the given phone number.
-
phoneNumber
:string
- Destination phone number to call. If the phone number does not exist, the call will be hung up with the proper reason. -
from
:string
- The field indicating what phone number should be used when making the call. -
viberCallOptions
:ViberCallOptions
- Optional additional options used to configure a viber call.
-
ViberCall
- Instance of theViberCall
.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let viberCall = infobipRTC.callViber('41793026727', '33712345678', PhoneCallOptions.builder().build());
Joins a room call on Infobip's WebRTC platform.
-
roomName
:string
- Name of the room to join. -
options
:RoomCallOptions
- Optional additional options used to configure a room call.
-
RoomCall
- Instance of theRoomCall
.
- Example of initiating an audio room call:
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let roomCall = infobipRTC.joinRoom('test_room', RoomCallOptions.builder().build());
- Example of initiating a video room call:
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
let roomCall = infobipRTC.joinRoom('test_room', RoomCallOptions.builder().setVideo(true).build());
Returns available audio input devices.
none
-
Promise<MediaDeviceInfo[]>
- Promise that resolves to an array containing available audio input devices info.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.getAudioInputDevices()
.then(devices => {
devices.forEach(device => console.log(device.label));
})
.catch(error => console.error(`Error: ${error.message}`));
Returns available audio output devices.
none
-
Promise<MediaDeviceInfo[]>
- Promise that resolves to an array containing available audio output devices info.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.getAudioOutputDevices()
.then(devices => {
devices.forEach(device => console.log(device.label));
})
.catch(error => console.error(`Error: ${error.message}`));
Returns available video input devices.
none
-
Promise<MediaDeviceInfo[]>
- Promise that resolves to an array containing available video input devices info.
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.getVideoInputDevices()
.then(devices => {
devices.forEach(device => console.log(device.label));
})
.catch(error => console.error(`Error: ${error.message}`));
Sets the audio input device with the given id as the default option for all subsequent calls.
-
deviceId
:string
- Audio input device identifier.
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.setAudioInputDevice('audioDeviceId');
Sets the video input device with the given id as the default option for all subsequent calls.
-
deviceId
:string
- Video input device identifier.
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.setVideoInputDevice('videoDeviceId');
Clears the specified audio input device as the default device. Instead, the system default will be used for subsequent calls.
-
deviceId
:string
- Audio input device identifier.
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.unsetAudioInputDevice('audioDeviceId');
Clears the specified video input device as the default device. Instead, the system default will be used for subsequent calls.
-
deviceId
:string
- Video input device identifier.
N/A
let infobipRTC = createInfobipRtc('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
infobipRTC.connect();
infobipRTC.unsetVideoInputDevice('videoDeviceId');