-
- version
- init()
- connect()
- disconnect()
- joinRoom()
- quitRoom()
- call()
- openDataChannel()
- endCall()
- endCalls()
- getMediaSources()
- startStream()
- stopStream()
- attachStream()
- detachStream()
- getPresence()
- setPresence()
- muteMicrophone()
- muteSound()
- muteAllSounds()
- muteVideo()
- isMicrophoneMuted()
- isAllSoundsMuted()
- isVideoMuted()
- getLocalStreams()
- getRemoteStreams()
- getDataChannels()
- getRoomMembers()
- addStream()
- removeStream()
- monitorAudioActivity()
- isConnected()
- isCompatible()
- isScreenSharingCompatible()
- getWebRTCPluginURL()
- isWebRTCPluginUsed()
- isWebRTCPluginAvailable()
-
signaling
-
streams
-
channels
-
Signaling Events
-
Streams Events
-
Data Channels Events
events
types
values
parameters/arguments
functions/methods
properties
Functions
onBistriConferenceReady = function(){…}
onBistriConferenceReady()
is called when the JavaScript SDK has been loaded and is ready to use.Return
void
.
Usage:
var onBistriConferenceReady = function(){ // your code goes here };
Objects
BistriConference (bc)
version
string
Usage:
console.log( BistriConference.version ); ➥ "3.0.b-647efef"
init( conf )
Return
void
.
Usage:
BistriConference.init( { appId: "125...445", appKey: "edhh64...99v35", userName: "John Doe" } );
Parameters:
conf
:object
, JavaScript SDK settings.
Configuration keys:appId
:string
, your application id (mandatory).appKey
:string
, your application key (mandatory).userId
:string
, user ID (optional). If no ID is passed, the server will generate its own “technical” IDuserName
:string
, user display name (optional). Default value is""
chromeExtensionId
:string
, chrome extension id for screen-sharing feature (optional). To learn how to build your own extension please read: https://github.com/bistri/screensharing-extensions/tree/master/chrome-screensharing-extensionfirefoxExtensionId
:string
, firefox extension id for screen-sharing feature (optional). To learn how to build your own extension please read: https://github.com/bistri/screensharing-extensions/tree/master/firefox-screensharing-extensionextAutoReload
:boolean
, automatically reload the page once the screen-sharing extension has been installed (optional).
Default value istrue
autoCloseOnExit
:boolean
, automatically close all connections when leaving/reloading the page (optional). Default value istrue
debug
:boolean
, allow to log some information (optional). Default value isfalse
Note: your application ID and application Key could be retreived from your developer account
➥ https://api.developers.bistri.com/admin/applications
Warning: we strongly recommend to set a referrer filter to prevent your application keys from being used by anybody. You can set it when editing your application parameters. Eg: my.domain.com* (don’t forget to add the wildcard suffix to match all your referrers)
➥ Go to applications list
connect()
Return
void
.
Usage:
BistriConference.connect();
Event onConnected
is triggered when the session has been successfully opened, otherwise event onError
is triggered.
disconnect()
Return
void
.
Usage:
BistriConference.disconnect();
Event onDisconnected
is triggered when the session has been closed.
joinRoom( roomName [, roomMaxCapacity] )
You can set the maximum number of participants in a room by using the roomMaxCapacity parameter. Only the first person joining the room can set the limitation. By default the maximum number of participants is limited to 256.
Return
void
.
Note:
The maximum number of participants must be adjusted according to the kind of calls that will be done. We strongly recommend to limit audio/video calls to 4 participants, since most of actual CPUs can’t encode/decode more than 4 video streams at a time. Pure audio conference can be limited to 10 participants. Data-channels are not concerned by those limitations.
Usage:
BistriConference.joinRoom( "my_conference_room", 4 );
Parameters:
roomName
:string
, room to join.roomMaxCapacity
:integer
, max room participants (optional).
If the room doesn’t exist, it will be created.
Event onJoinedRoom
is triggered when user has successfully joined the room, other members already present into the room will receive an event onPeerJoinedRoom
.
Otherwise event onJoinRoomError
is triggered
quitRoom( roomName )
Return
void
.
Usage:
BistriConference.quitRoom( "my_conference_room" );
Parameters:
roomName
:string
, room to quit
Event onQuittedRoom
is triggered when the user has leaved the room, other room members will receive event onPeerQuittedRoom
.
Otherwise an event onQuitRoomError
is triggered.
call( remoteUserId, roomName, options )
Return
void
.
Usage:
BistriConference.call( "rfpWEk", "my_conference_room" );
Parameters:
remoteUserId
:string
, ID of the remote user to call.roomName
:string
, room where the call take place.options
:object
, optional parameters.
Available options:stream
:MediaStream
, stream to use for the call.sendonly
:boolean
, if true remote streams will be not accepted.audio-codec
:string
, preferred audio codec: Opus/48000, ISAC/32000, ISAC/16000 (Chrome only).audio-bitrate
:integer
, audio bitrate kb/s (Chrome only).video-bitrate
:integer
, video bitrate kb/s (Chrome only).
If the user hasn’t joined the room previously, he will be automatically added to the room and event onJoinedRoom
will be triggered
At this point there are 2 cases:
1 – The user you are calling is already present in the room:
the call is processed and event onStreamAdded
is triggered shortly after, when the remote audio/video stream is received.
2 – The user you are calling is not present in the room yet, but he is connected to the service:
event onIncomingRequest
is triggered on the remote user side to invite him to join the room for a call.
Note: to know if a remote user is connected to the service you can use the getPresence()
method and check if he is online or not.
openDataChannel( remoteUserId, label, roomName )
Return
void
.
Usage:
BistriConference.openDataChannel( "rfpWEk", "chat_channel", "my_conference_room" );
Parameters:
remoteUserId
:string
, ID of the remote user to call.label
:string
, data channel label.roomName
:string
, room where the call take place.
If the user hasn’t joined the room previously, he will be automatically added to the room and event onJoinedRoom
will be triggered
As for the call()
method there are 2 cases:
1 – The user you are calling is already present in the room:
the request is processed and event onDataChannelCreated
is triggered on the local user side and event onDataChannelRequested
is triggered on the remote user side.
2 – The user you are calling is not present in the room yet, but he is connected to the service:
event onIncomingRequest
is triggered on the remote user side to invite him to join the room for a call.
Note: to know if a remote user is connected to the service you can use the getPresence()
method and check if he is online or not.
endCall( remoteUserId, roomName )
Return
void
.
Usage:
BistriConference.endCall( "rfpWEk", "my_conference_room" );
Parameters:
remoteUserId
:string
, ID of the remote user.roomName
:string
, room where the call take place.
Event onStreamClosed
is triggered on the remote side when the call ended.
endCalls( roomName )
Return
void
.
Usage:
BistriConference.endCalls( "my_conference_room" );
Parameters:
roomName
:string
, room where the call take place.
Event onStreamClosed
is triggered on the remote side when the call ended.
getMediaSources( callback )
Return an
array
of sources if browser is Google Chrome, either return boolean
false.
Usage:
BistriConference.getMediaSources( function( sources ){ console.log( "Sources:", sources ) } ); ➥ Sources: [ { facing: "", id: "96d64b0...", kind: "audio", label: "Default" }, { ... }, { ... } ]
Parameters:
callback
:function
called when sources have been listed.
startStream( mediaConstraints, callback )
Return
void
Because of security purpose, HTTPS is required by the browser to access to the local stream !.
Usage:
BistriConference.startStream( "320x240:12", function( stream ){ // display stream into the page BistriConference.attachStream( stream, document.body ); } );
Parameters:
mediaConstraints
:object
orstring
, media constraints.
Possible values are:{ video: true, audio: true }
: classical constraints object.pure-audio
: audio only stream.{video-width}x{video-height}[:{frame-rate}]
: user defined resolution, frame rate is optional.webcam-hd
: “1280×720” webcam stream.webcam-sd
: “640×480” webcam stream.screen-sharing
: screen sharing. This feature is only available for Chrome and Firefox (desktop).
Both Chrome and Firefox require an add-on to use the screen-sharing
➥ Chrome extension sources are available on our GitHub.
callback
: function
called when the local stream start to flow.stopStream( localStream, callback )
Return
void
.
Usage:
BistriConference.stopStream( stream, function(){ // remove stream from the page BistriConference.detachStream( stream ); } );
Parameters:
localStream
:MediaStream
, stream to stop.callback
:function
called when the local stream has been stopped.
When no callback has been passed to the method to handle the stopped stream, the event onStreamClosed
is triggered on the local side.
attachStream( stream, node, options )
Return audio/video html
node
.
Usage:
BistriConference.attachStream( stream, document.body, { autoplay: true, fullscreen: true, controls: true, mirror: true } );
Parameters:
stream
:MediaStream
, stream to attach to the DOM node.node
:object
, DOM node in which the media will be inserted.options
:object
, display options, optional
Available options:autoplay
:boolean
Start to play automatically the stream once inserted into the page.
Default value is set totrue
.fullscreen
:boolean
Allow the user to switch to fullscreen mode by clicking on the video.
Default value is set tofalse
.controls
:boolean
Display video controls.
Default value is set tofalse
.mirror
:boolean
flip video on vertical axis (like in a mirror).
Default value is set tofalse
.
detachStream( stream )
Return
void
.
Usage:
BistriConference.detachStream( stream );
Parameters:
stream
:MediaStream
, stream to remove.
getPresence( remoteUserId )
Return
void
.
Usage:
BistriConference.getPresence( 'rfpWEk' );
Parameters:
remoteUserId
:string
, remote user ID.
Event onPresence
is triggered when the presence is received.
setPresence( presenceStatus )
Return
void
.
Usage:
BistriConference.setPresence( 'away' );
Parameters:
status
:string
, local user status.
Possible values are:online
away
busy
offline
muteMicrophone( status )
Return
void
.
Usage:
BistriConference.muteMicrophone( true );
Parameters:
status
:boolean
, microphone status.
muteSound( stream, status )
Return
void
.
Usage:
BistriConference.muteSound( stream, true );
Parameters:
stream
:MediaStream
, stream to mute.status
:boolean
, sound status.
muteAllSounds( status )
Return
void
.
Usage:
BistriConference.muteAllSounds( true );
Parameters:
status
:boolean
, sound status.
muteVideo( stream, status )
Return
void
.
Usage:
BistriConference.muteVideo( stream, true );
Parameters:
stream
:MediaStream
, stream to mute.status
:boolean
, video status.
Event onStreamMuteChange
is triggered on local and remote sides when the video track is un/muted.
isMicrophoneMuted()
Return
boolean
.
Usage:
console.log( "microphone muted: ", BistriConference.isMicrophoneMuted() ); ➥ microphone muted: true
isAllSoundsMuted()
Return
boolean
.
Usage:
console.log( "all sounds muted: ", BistriConference.isAllSoundsMuted() ); ➥ all sounds muted: true
isVideoMuted()
Return
boolean
.
Usage:
console.log( "local video muted: ", BistriConference.isVideoMuted() ); ➥ all sounds muted: true
getLocalStreams()
array
of local media stream objects.
Usage:
console.log( BistriConference.getLocalStreams() ); ➥ [ MediaStream, MediaStream, ... ]
getRemoteStreams( roomName )
object
containing pairs of remote user ID / remote MediaStream objects.
Usage:
console.log( BistriConference.getRemoteStreams() ); ➥ { 'St9d9JU7': MediaStream, 'xHoYffVm': MediaStream, ... }
Parameters:
roomName
:string
, room name. Use this optional parameter to get the streams of a particular room.
getDataChannels( roomName )
object
containing pairs of remote user ID / remote Data Channels objects.
Usage:
console.log( BistriConference.getDataChannels( roomName ) ); ➥ { 'St9d9JU7': { 'chat': DataChannel, 'filetransfert': DataChannel }, ... }
Parameters:
roomName
:string
, room name.
getRoomMembers( roomName )
array
of users object
Usage:
console.log( BistriConference.getRoomMembers( roomName ) ); ➥ [ { id: 'St9d9JU7', name: 'Jane Smith' }, ... ]
Parameters:
roomName
:string
, room name.
addStream( remoteUserId, roomName, stream )
Return
void
.
Usage:
BistriConference.addStream( 'St9d9JU7', 'my_conference_room', stream );
Parameters:
remoteUserId
:string
, ID of the remote user.roomName
:string
, room where the call take place.stream
:MediaStream
, stream to add.
Event onStreamAdded
is triggered on the remote user side once the stream has been added.
removeStream( remoteUserId, roomName, stream )
Return
void
.
Usage:
BistriConference.removeStream( 'St9d9JU7', 'my_conference_room', stream );
Parameters:
remoteUserId
:string
, ID of the remote user.roomName
:string
, room where the call take place.stream
:MediaStream
, stream to remove.
Event onStreamClosed
is triggered on the remote user side once the stream has been removed.
monitorAudioActivity( stream, callback )
Note: because of a Chrome bug it is not possible to monitor remote streams.
Return
void
.
Usage:
BistriConference.monitorAudioActivity( stream, function( audioLevel ){ console.log( 'level:', audioLevel ); } ); ➥ level: 34 ➥ level: 67
Parameters:
stream
:MediaStream
, stream to monitor.callback
:function
, executed when an audio activity is detected.
isConnected()
boolean
according to the api server connection state
Usage:
console.log( "is connected to api server:", BistriConference.isConnected() ); ➥ is connected to api server: true
isCompatible()
boolean
according to the WebRTC compatibility
Usage:
console.log( "is browser compatible:", BistriConference.isCompatible() ); ➥ is browser compatible: true
isScreenSharingCompatible()
boolean
according to the screen-sharing compatibility
Usage:
console.log( "is screen-sharing compatible:", BistriConference.isScreenSharingCompatible() ); ➥ is screen-sharing compatible: true
getWebRTCPluginURL()
Return
string
Usage:
console.log( "plugin URL:", BistriConference.getWebRTCPluginURL() ); ➥ plugin URL: https://temasys.atlassian.net/wiki/display/TWPP/WebRTC+Plugins
isWebRTCPluginUsed()
Return
boolean
Usage:
console.log( "is WebRTC plugin used:", BistriConference.isWebRTCPluginUsed() ); ➥ is WebRTC plugin used: true
isWebRTCPluginAvailable()
Return
boolean
Usage:
console.log( "is WebRTC plugin available:", BistriConference.isWebRTCPluginAvailable() ); ➥ is WebRTC plugin available: true
signaling
bind( eventName, callback )
Return a handler
object
.
Usage:
BistriConference.signaling.bind( 'onConnected', function( sessionData ){ ... } );
Parameters:
eventName
:string
, event name.callback
:function
executed when the related event is triggered.
Events:
onError
, onConnected
, onJoinedRoom
,
onJoinRoomError
, onQuittedRoom
, onQuitRoomError
,
onPeerJoinedRoom
, onPeerQuittedRoom
, onDisconnected
,
onIncomingRequest
, onPresence
, onStreamMuteChange
,
onClientUpdateRequired
.
unbind( handler )
Return
void
.
Usage:
var handler = BistriConference.signaling.bind( 'onConnected', function(){...} ); ... BistriConference.signaling.unbind( handler );
Parameters:
handler
:object
returned bybind()
method.
streams
bind( eventName, callback )
Return a handler
object
.
Usage:
BistriConference.streams.bind( 'onStreamAdded', function( stream, id ){ ... } );
Parameters:
eventName
:string
, event name.callback
:function
executed when the related event is triggered.
Events:
onStreamAdded
, onStreamClosed
, onStreamRemoved
, onStreamError
, onStreamStatsUpdated
.
unbind( handler )
Return
void
.
Usage:
var handler = BistriConference.streams.bind( 'onStreamAdded', function(){...} ); ... BistriConference.streams.unbind( handler );
Parameters:
handler
:object
returned bybind()
method.
channels
bind( eventName, callback )
Return a handler
object
.
Usage:
BistriConference.channels.bind( 'onDataChannelRequested', function( dataChannel ){ ... } );
Parameters:
eventName
:string
, event name.callback
:function
executed when the related event is triggered.
Events:
unbind( handler )
Return
void
.
Usage:
var handler = BistriConference.channels.bind( 'onDataChannelRequested', function(){...} ); ... BistriConference.channels.unbind( handler );
Parameters:
handler
:object
returned bybind()
method.
Data Channel
label
Usage:
console.log( "data channel label:", dataChannel.label ); ➥ data channel label: chat_channel
send( message )
Return
void
.
Usage:
dataChannel.send( "my message" );
Parameters:
message
:string
, message to send.
onMessage
callback is invoked on the remote user side when the message is received.
close()
Return
void
.
Usage:
dataChannel.close();
onClosed
callback is invoked on the remote user side when the data channel is closed.
onOpen = function(){…}
Return
void
.
Usage:
dataChannel.onOpen = function(){ console.log( "Data Channel open" ); };
onMessage = function( message ){…}
Return
void
.
Usage:
dataChannel.onMessage = function( event ){ console.log( "New Message:", event.data ); };
Arguments:
event
:object
, message received.
onClose = function(){…}
Return
void
.
Usage:
dataChannel.onClose = function(){ console.log( "Data Channel closed" ); };
onError = function( error ){…}
Return
void
.
Usage:
dataChannel.onError = function( error ){ console.log( "Data Channel error:", error ); };
Arguments:
error
:string
, error message.
Events
Signaling Events
onError( error )
Arguments:
error
:JSON
, error object.
Object detail:{ "code": "xxx", // error code "text": "..." // error reason }
Error codes:
- 000: api access not authorized
- 301: no room found
- 401: failed to save user data
onConnected( session )
Event linked to:
connect()
Arguments:
session
:JSON
, session data.
Object detail:{ "clientVersion": "3.0.b-647efef", // last JavaScript SDK version available "id": "rfpWEk" // user session id }
onJoinedRoom( room )
Event linked to:
joinRoom()
, call()
, openDataChannel()
Arguments:
room
:JSON
, room data.
Object detail:{ "room": "aUpS45g7J0w" // room id "members":[ // array of remote users already connected to room { id: "aVlxUi", // remote user id name: "Jane Doe" // remote user display name }, ... ], }
onJoinRoomError( error )
Event linked to:
joinRoom()
, call()
, openDataChannel()
Arguments:
error
:JSON
, error data.
Object detail:{ "code": "xxx", // error code "text": "..." // error reason }
Error codes:
- 101: user is already present in room
- 102: the room reached its max capacity
- 103: the room doesn\’t exists
- 104: user is not present in room
- 105: forbidden chars in room name
- 106: maximum simultaneous joined rooms reached
onQuittedRoom( room )
Event linked to:
quitRoom()
Arguments:
room
:JSON
, room data.
Object detail:{ "room": "aUpS45g7J0w" // room id }
onQuitRoomError( error )
Event linked to:
quitRoom()
Arguments:
error
:JSON
, error data.
Object detail:{ "code": "xxx", // error code "text": "..." // error reason }
Error codes:
- 201: no room found
onPeerJoinedRoom( peer )
Event linked to:
joinRoom()
, call()
, openDataChannel()
Arguments:
peer
:JSON
, peer data.
Object detail:{ "room":"aUpS45g7J0w", // room id "name":"John Doe", // peer display name "pid":"rfpWEk" // peer id }
onPeerQuittedRoom( peer )
Event linked to:
quitRoom()
Arguments:
peer
:JSON
, peer data.
Object detail:{ "room":"aUpS45g7J0w", // room id "pid":"rfpWEk" // peer id }
onDisconnected()
Event linked to:
disconnect()
onIncomingRequest( request )
Event linked to:
call()
Arguments:
request
:JSON
, request data.
Object detail:{ "room":"aUpS45g7J0w", // room id "pid":"rfpWEk", // peer id "event": "call" // request: "call" for a call request, "call-stop": to end a call, "datachannel": for a datachannel request }
onPresence( presence )
Event linked to:
getPresence()
Arguments:
presence
:JSON
, presence data.
Object detail:{ id: "rfpWEk", // contact id presence: "online" // contact presence status }
onClientUpdateRequired( version )
Event linked to:
connect()
Arguments:
version
:JSON
, version data.
Object detail:{ clientVersion: "3.0.b-647efef", // new client version }
onExtensionInstallStarted()
onExtensionInstalled()
onExtensionInstallFailed()
Streams Events
onStreamAdded( stream, id )
Event linked to:
call()
, addStream()
Arguments:
stream
:MediaStream
, remote stream.id
:string
, remote user id.
onStreamClosed( stream, id )
Event linked to:
endCall()
, endCalls()
, removeStream()
Arguments:
stream
:MediaStream
, remote stream.id
:string
, remote user id.
onStreamRemoved( stream, id )
Event linked to:
removeStream()
Arguments:
stream
:MediaStream
, remote stream.id
:string
, remote user id.
onStreamError( error )
Event linked to:
startStream()
Arguments:
error
:Object
, error information.
onStreamMuteChange( streamStatus, pid )
Event linked to:
muteVideo()
Arguments:
streamStatus
:Boolean
, video stream status, true if mute.pid
:String
, peer id.
onStreamStatsUpdated( stats, id )
Note: chrome only feature
Arguments:
stats
:JSON
, stats data.
Object detail:{ "local":{ ... }, // sent stream stats "remote":{ ... } // received stream stats }
id
:string
, remote user id.
Data Channels Events
onDataChannelCreated( dataChannel, id )
Event linked to:
openDataChannel()
Arguments:
dataChannel
:object
, Data Channel. More about Data Channelid
:string
, remote user id.
onDataChannelRequested( dataChannel, id )
Event linked to:
openDataChannel()
Arguments:
dataChannel
:object
, Data Channel. More about Data Channelid
:string
, remote user id.