2018-04-26 15:33:47 +02:00
"use strict" ;
/ *
2018-05-06 02:20:25 +02:00
* ( C ) Copyright 2017 - 2018 OpenVidu ( https : //openvidu.io/)
2018-04-26 15:33:47 +02:00
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
*
* /
exports . _ _esModule = true ;
2018-05-08 13:01:34 +02:00
var Connection _1 = require ( "./Connection" ) ;
var Subscriber _1 = require ( "./Subscriber" ) ;
2018-04-26 15:33:47 +02:00
var ConnectionEvent _1 = require ( "../OpenViduInternal/Events/ConnectionEvent" ) ;
var RecordingEvent _1 = require ( "../OpenViduInternal/Events/RecordingEvent" ) ;
var SessionDisconnectedEvent _1 = require ( "../OpenViduInternal/Events/SessionDisconnectedEvent" ) ;
var SignalEvent _1 = require ( "../OpenViduInternal/Events/SignalEvent" ) ;
var StreamEvent _1 = require ( "../OpenViduInternal/Events/StreamEvent" ) ;
2018-07-11 11:47:53 +02:00
var StreamPropertyChangedEvent _1 = require ( "../OpenViduInternal/Events/StreamPropertyChangedEvent" ) ;
2018-04-26 15:33:47 +02:00
var OpenViduError _1 = require ( "../OpenViduInternal/Enums/OpenViduError" ) ;
var VideoInsertMode _1 = require ( "../OpenViduInternal/Enums/VideoInsertMode" ) ;
var platform = require ( "platform" ) ;
var EventEmitter = require ( "wolfy87-eventemitter" ) ;
/ * *
* Represents a video call . It can also be seen as a videoconference room where multiple users can connect .
2018-06-01 14:39:38 +02:00
* Participants who publish their videos to a session can be seen by the rest of users connected to that specific session .
2018-04-26 15:33:47 +02:00
* Initialized with [ [ OpenVidu . initSession ] ] method
* /
var Session = /** @class */ ( function ( ) {
/ * *
* @ hidden
* /
2018-05-03 11:48:57 +02:00
function Session ( openvidu ) {
2018-06-01 14:39:38 +02:00
/ * *
* Collection of all StreamManagers of this Session ( [ [ Publisher ] ] and [ [ Subscriber ] ] )
* /
this . streamManagers = [ ] ;
2018-04-26 15:33:47 +02:00
// This map is only used to avoid race condition between 'joinRoom' response and 'onParticipantPublished' notification
/ * *
* @ hidden
* /
this . remoteStreamsCreated = { } ;
/ * *
* @ hidden
* /
this . remoteConnections = { } ;
/ * *
* @ hidden
* /
this . speakingEventsEnabled = false ;
this . ee = new EventEmitter ( ) ;
this . openvidu = openvidu ;
}
/ * *
* Connects to the session using ` token ` . Parameter ` metadata ` allows you to pass extra data to share with other users when
* they receive ` streamCreated ` event . The structure of ` metadata ` string is up to you ( maybe some standarized format
* as JSON or XML is a good idea ) , the only restriction is a maximum length of 10000 chars .
*
* This metadata is not considered secure , as it is generated in the client side . To pass securized data , add it as a parameter in the
* token generation operation ( through the API REST , openvidu - java - client or openvidu - node - client ) .
*
* Only after the returned Promise is successfully resolved [ [ Session . connection ] ] object will be available and properly defined .
*
* # # # # Events dispatched
*
* The [ [ Session ] ] object of the local participant will first dispatch one or more ` connectionCreated ` events upon successful termination of this method :
* - First one for your own local Connection object , so you can retrieve [ [ Session . connection ] ] property .
* - Then one for each remote Connection previously connected to the Session , if any . Any other remote user connecting to the Session after you have
* successfully connected will also dispatch a ` connectionCreated ` event when they do so .
*
2018-06-01 14:39:38 +02:00
* The [ [ Session ] ] object of the local participant will also dispatch a ` streamCreated ` event for each remote active [ [ Publisher ] ] that was already streaming
* when connecting , just after dispatching all remote ` connectionCreated ` events .
2018-04-26 15:33:47 +02:00
*
* The [ [ Session ] ] object of every other participant connected to the session will dispatch a ` connectionCreated ` event .
*
* See [ [ ConnectionEvent ] ] and [ [ StreamEvent ] ] to learn more .
*
2018-06-01 14:39:38 +02:00
* @ returns A Promise to which you must subscribe that is resolved if the the connection to the Session was successful and rejected with an Error object if not
2018-04-26 15:33:47 +02:00
*
* /
2018-05-08 10:40:46 +02:00
Session . prototype . connect = function ( token , metadata ) {
2018-04-26 15:33:47 +02:00
var _this = this ;
2018-05-08 10:40:46 +02:00
return new Promise ( function ( resolve , reject ) {
2018-05-03 11:48:57 +02:00
_this . processToken ( token ) ;
2018-04-26 15:33:47 +02:00
if ( _this . openvidu . checkSystemRequirements ( ) ) {
// Early configuration to deactivate automatic subscription to streams
_this . options = {
sessionId : _this . sessionId ,
participantId : token ,
metadata : ! ! metadata ? _this . stringClientMetadata ( metadata ) : ''
} ;
_this . connectAux ( token ) . then ( function ( ) {
resolve ( ) ;
} ) [ "catch" ] ( function ( error ) {
reject ( error ) ;
} ) ;
}
else {
reject ( new OpenViduError _1 . OpenViduError ( OpenViduError _1 . OpenViduErrorName . BROWSER _NOT _SUPPORTED , 'Browser ' + platform . name + ' ' + platform . version + ' is not supported in OpenVidu' ) ) ;
}
2018-05-08 10:40:46 +02:00
} ) ;
2018-04-26 15:33:47 +02:00
} ;
/ * *
* Leaves the session , destroying all streams and deleting the user as a participant .
*
* # # # # Events dispatched
*
* The [ [ Session ] ] object of the local participant will dispatch a ` sessionDisconnected ` event .
* This event will automatically unsubscribe the leaving participant from every Subscriber object of the session ( this includes closing the WebRTCPeer connection and disposing all MediaStreamTracks )
2018-06-01 14:39:38 +02:00
* and also deletes any HTML video element associated to each Subscriber ( only those [ created by OpenVidu Browser ] ( / d o c s / h o w - d o - i / m a n a g e - v i d e o s / # l e t - o p e n v i d u - t a k e - c a r e - o f - t h e - v i d e o - p l a y e r s ) ) .
* For every video removed , each Subscriber object will dispatch a ` videoElementDestroyed ` event .
2018-07-11 11:47:53 +02:00
* Call ` event.preventDefault() ` upon event ` sessionDisconnected ` to avoid this behavior and take care of disposing and cleaning all the Subscriber objects yourself .
2018-06-01 14:39:38 +02:00
* See [ [ SessionDisconnectedEvent ] ] and [ [ VideoElementEvent ] ] to learn more to learn more .
2018-04-26 15:33:47 +02:00
*
* The [ [ Publisher ] ] object of the local participant will dispatch a ` streamDestroyed ` event if there is a [ [ Publisher ] ] object publishing to the session .
2018-06-01 14:39:38 +02:00
* This event will automatically stop all media tracks and delete any HTML video element associated to it ( only those [ created by OpenVidu Browser ] ( / d o c s / h o w - d o - i / m a n a g e - v i d e o s / # l e t - o p e n v i d u - t a k e - c a r e - o f - t h e - v i d e o - p l a y e r s ) ) .
* For every video removed , the Publisher object will dispatch a ` videoElementDestroyed ` event .
2018-07-11 11:47:53 +02:00
* Call ` event.preventDefault() ` upon event ` streamDestroyed ` if you want to clean the Publisher object on your own or re - publish it in a different Session ( to do so it is a mandatory requirement to call ` Session.unpublish() `
2018-06-01 14:39:38 +02:00
* or / and ` Session.disconnect() ` in the previous session ) . See [ [ StreamEvent ] ] and [ [ VideoElementEvent ] ] to learn more .
2018-04-26 15:33:47 +02:00
*
* The [ [ Session ] ] object of every other participant connected to the session will dispatch a ` streamDestroyed ` event if the disconnected participant was publishing .
* This event will automatically unsubscribe the Subscriber object from the session ( this includes closing the WebRTCPeer connection and disposing all MediaStreamTracks )
2018-06-01 14:39:38 +02:00
* and also deletes any HTML video element associated to that Subscriber ( only those [ created by OpenVidu Browser ] ( / d o c s / h o w - d o - i / m a n a g e - v i d e o s / # l e t - o p e n v i d u - t a k e - c a r e - o f - t h e - v i d e o - p l a y e r s ) ) .
* For every video removed , the Subscriber object will dispatch a ` videoElementDestroyed ` event .
2018-07-11 11:47:53 +02:00
* Call ` event.preventDefault() ` upon event ` streamDestroyed ` to avoid this default behavior and take care of disposing and cleaning the Subscriber object yourself .
2018-06-01 14:39:38 +02:00
* See [ [ StreamEvent ] ] and [ [ VideoElementEvent ] ] to learn more .
2018-04-26 15:33:47 +02:00
*
* The [ [ Session ] ] object of every other participant connected to the session will dispatch a ` connectionDestroyed ` event in any case . See [ [ ConnectionEvent ] ] to learn more .
* /
Session . prototype . disconnect = function ( ) {
this . leave ( false , 'disconnect' ) ;
} ;
/ * *
* Subscribes to a ` stream ` , adding a new HTML video element to DOM with ` subscriberProperties ` settings . This method is usually called in the callback of ` streamCreated ` event .
*
* # # # # Events dispatched
*
2018-06-01 14:39:38 +02:00
* The [ [ Subscriber ] ] object will dispatch a ` videoElementCreated ` event once the HTML video element has been added to DOM ( only if you
* [ let OpenVidu take care of the video players ] ( / d o c s / h o w - d o - i / m a n a g e - v i d e o s / # l e t - o p e n v i d u - t a k e - c a r e - o f - t h e - v i d e o - p l a y e r s ) ) . S e e [ [ V i d e o E l e m e n t E v e n t ] ] t o l e a r n m o r e .
2018-04-26 15:33:47 +02:00
*
2018-06-01 14:39:38 +02:00
* The [ [ Subscriber ] ] object will dispatch a ` streamPlaying ` event once the remote stream starts playing . See [ [ StreamManagerEvent ] ] to learn more .
2018-04-26 15:33:47 +02:00
*
* @ param stream Stream object to subscribe to
2018-06-01 14:39:38 +02:00
* @ param targetElement HTML DOM element ( or its ` id ` attribute ) in which the video element of the Subscriber will be inserted ( see [ [ SubscriberProperties . insertMode ] ] ) . If * null * or * undefined * no default video will be created for this Subscriber .
* You can always call method [ [ Subscriber . addVideoElement ] ] or [ [ Subscriber . createVideoElement ] ] to manage the video elements on your own ( see [ Manage video players ] ( / d o c s / h o w - d o - i / m a n a g e - v i d e o s ) s e c t i o n )
2018-04-26 15:33:47 +02:00
* @ param completionHandler ` error ` parameter is null if ` subscribe ` succeeds , and is defined if it fails .
* /
Session . prototype . subscribe = function ( stream , targetElement , param3 , param4 ) {
var properties = { } ;
if ( ! ! param3 && typeof param3 !== 'function' ) {
properties = {
2018-04-27 11:08:03 +02:00
insertMode : ( typeof param3 . insertMode !== 'undefined' ) ? ( ( typeof param3 . insertMode === 'string' ) ? VideoInsertMode _1 . VideoInsertMode [ param3 . insertMode ] : properties . insertMode ) : VideoInsertMode _1 . VideoInsertMode . APPEND ,
2018-04-26 15:33:47 +02:00
subscribeToAudio : ( typeof param3 . subscribeToAudio !== 'undefined' ) ? param3 . subscribeToAudio : true ,
subscribeToVideo : ( typeof param3 . subscribeToVideo !== 'undefined' ) ? param3 . subscribeToVideo : true
} ;
}
else {
properties = {
insertMode : VideoInsertMode _1 . VideoInsertMode . APPEND ,
subscribeToAudio : true ,
subscribeToVideo : true
} ;
}
var completionHandler ;
if ( ! ! param3 && ( typeof param3 === 'function' ) ) {
completionHandler = param3 ;
}
else if ( ! ! param4 ) {
completionHandler = param4 ;
}
console . info ( 'Subscribing to ' + stream . connection . connectionId ) ;
stream . subscribe ( )
. then ( function ( ) {
console . info ( 'Subscribed correctly to ' + stream . connection . connectionId ) ;
if ( completionHandler !== undefined ) {
completionHandler ( undefined ) ;
}
} ) [ "catch" ] ( function ( error ) {
if ( completionHandler !== undefined ) {
completionHandler ( error ) ;
}
} ) ;
2018-05-08 13:01:34 +02:00
var subscriber = new Subscriber _1 . Subscriber ( stream , targetElement , properties ) ;
2018-06-01 14:39:38 +02:00
if ( ! ! subscriber . targetElement ) {
stream . streamManager . createVideoElement ( subscriber . targetElement , properties . insertMode ) ;
}
2018-04-26 15:33:47 +02:00
return subscriber ;
} ;
Session . prototype . subscribeAsync = function ( stream , targetElement , properties ) {
var _this = this ;
return new Promise ( function ( resolve , reject ) {
var subscriber ;
var callback = function ( error ) {
if ( ! ! error ) {
reject ( error ) ;
}
else {
resolve ( subscriber ) ;
}
} ;
if ( ! ! properties ) {
subscriber = _this . subscribe ( stream , targetElement , properties , callback ) ;
}
else {
subscriber = _this . subscribe ( stream , targetElement , callback ) ;
}
} ) ;
} ;
/ * *
2018-06-01 14:39:38 +02:00
* Unsubscribes from ` subscriber ` , automatically removing its associated HTML video elements .
2018-04-26 15:33:47 +02:00
*
* # # # # Events dispatched
*
2018-06-01 14:39:38 +02:00
* The [ [ Subscriber ] ] object will dispatch a ` videoElementDestroyed ` event for each video associated to it that was removed from DOM .
* Only videos [ created by OpenVidu Browser ] ( / d o c s / h o w - d o - i / m a n a g e - v i d e o s / # l e t - o p e n v i d u - t a k e - c a r e - o f - t h e - v i d e o - p l a y e r s ) ) w i l l b e a u t o m a t i c a l l y r e m o v e d
*
* See [ [ VideoElementEvent ] ] to learn more
2018-04-26 15:33:47 +02:00
* /
Session . prototype . unsubscribe = function ( subscriber ) {
var connectionId = subscriber . stream . connection . connectionId ;
console . info ( 'Unsubscribing from ' + connectionId ) ;
2018-06-01 14:39:38 +02:00
this . openvidu . sendRequest ( 'unsubscribeFromVideo' , { sender : subscriber . stream . connection . connectionId } , function ( error , response ) {
2018-04-26 15:33:47 +02:00
if ( error ) {
console . error ( 'Error unsubscribing from ' + connectionId , error ) ;
}
else {
console . info ( 'Unsubscribed correctly from ' + connectionId ) ;
}
subscriber . stream . disposeWebRtcPeer ( ) ;
subscriber . stream . disposeMediaStream ( ) ;
} ) ;
2018-06-01 14:39:38 +02:00
subscriber . stream . streamManager . removeAllVideos ( ) ;
2018-04-26 15:33:47 +02:00
} ;
/ * *
2018-06-01 14:39:38 +02:00
* Publishes to the Session the Publisher object
2018-04-26 15:33:47 +02:00
*
* # # # # Events dispatched
*
* The local [ [ Publisher ] ] object will dispatch a ` streamCreated ` event upon successful termination of this method . See [ [ StreamEvent ] ] to learn more .
*
2018-06-01 14:39:38 +02:00
* The local [ [ Publisher ] ] object will dispatch a ` streamPlaying ` once the media stream starts playing . See [ [ StreamManagerEvent ] ] to learn more .
2018-04-26 15:33:47 +02:00
*
* The [ [ Session ] ] object of every other participant connected to the session will dispatch a ` streamCreated ` event so they can subscribe to it . See [ [ StreamEvent ] ] to learn more .
*
2018-06-01 14:39:38 +02:00
* @ returns A Promise ( to which you can optionally subscribe to ) that is resolved only after the publisher was successfully published and rejected with an Error object if not
2018-04-26 15:33:47 +02:00
* /
Session . prototype . publish = function ( publisher ) {
var _this = this ;
return new Promise ( function ( resolve , reject ) {
publisher . session = _this ;
publisher . stream . session = _this ;
2018-07-11 11:47:53 +02:00
if ( ! publisher . stream . publishedOnce ) {
2018-04-26 15:33:47 +02:00
// 'Session.unpublish(Publisher)' has NOT been called
_this . connection . addStream ( publisher . stream ) ;
publisher . stream . publish ( )
. then ( function ( ) {
resolve ( ) ;
} ) [ "catch" ] ( function ( error ) {
reject ( error ) ;
} ) ;
}
else {
// 'Session.unpublish(Publisher)' has been called. Must initialize again Publisher
publisher . initialize ( )
. then ( function ( ) {
_this . connection . addStream ( publisher . stream ) ;
2018-06-01 14:39:38 +02:00
publisher . reestablishStreamPlayingEvent ( ) ;
2018-04-26 15:33:47 +02:00
publisher . stream . publish ( )
. then ( function ( ) {
resolve ( ) ;
} ) [ "catch" ] ( function ( error ) {
reject ( error ) ;
} ) ;
} ) [ "catch" ] ( function ( error ) {
reject ( error ) ;
} ) ;
}
} ) ;
} ;
/ * *
2018-06-01 14:39:38 +02:00
* Unpublishes from the Session the Publisher object .
2018-04-26 15:33:47 +02:00
*
* # # # # Events dispatched
*
* The [ [ Publisher ] ] object of the local participant will dispatch a ` streamDestroyed ` event .
2018-06-01 14:39:38 +02:00
* This event will automatically stop all media tracks and delete any HTML video element associated to this Publisher
* ( only those videos [ created by OpenVidu Browser ] ( / d o c s / h o w - d o - i / m a n a g e - v i d e o s / # l e t - o p e n v i d u - t a k e - c a r e - o f - t h e - v i d e o - p l a y e r s ) ) .
* For every video removed , the Publisher object will dispatch a ` videoElementDestroyed ` event .
2018-07-11 11:47:53 +02:00
* Call ` event.preventDefault() ` upon event ` streamDestroyed ` if you want to clean the Publisher object on your own or re - publish it in a different Session .
2018-04-26 15:33:47 +02:00
*
* The [ [ Session ] ] object of every other participant connected to the session will dispatch a ` streamDestroyed ` event .
2018-06-01 14:39:38 +02:00
* This event will automatically unsubscribe the Subscriber object from the session ( this includes closing the WebRTCPeer connection and disposing all MediaStreamTracks ) and
* delete any HTML video element associated to it ( only those [ created by OpenVidu Browser ] ( / d o c s / h o w - d o - i / m a n a g e - v i d e o s / # l e t - o p e n v i d u - t a k e - c a r e - o f - t h e - v i d e o - p l a y e r s ) ) .
* For every video removed , the Subscriber object will dispatch a ` videoElementDestroyed ` event .
2018-07-11 11:47:53 +02:00
* Call ` event.preventDefault() ` upon event ` streamDestroyed ` to avoid this default behavior and take care of disposing and cleaning the Subscriber object on your own .
2018-04-26 15:33:47 +02:00
*
2018-06-01 14:39:38 +02:00
* See [ [ StreamEvent ] ] and [ [ VideoElementEvent ] ] to learn more .
2018-04-26 15:33:47 +02:00
* /
Session . prototype . unpublish = function ( publisher ) {
var stream = publisher . stream ;
if ( ! stream . connection ) {
console . error ( 'The associated Connection object of this Publisher is null' , stream ) ;
return ;
}
else if ( stream . connection !== this . connection ) {
console . error ( 'The associated Connection object of this Publisher is not your local Connection.' +
"Only moderators can force unpublish on remote Streams via 'forceUnpublish' method" , stream ) ;
return ;
}
else {
console . info ( 'Unpublishing local media (' + stream . connection . connectionId + ')' ) ;
this . openvidu . sendRequest ( 'unpublishVideo' , function ( error , response ) {
if ( error ) {
console . error ( error ) ;
}
else {
console . info ( 'Media unpublished correctly' ) ;
}
} ) ;
stream . disposeWebRtcPeer ( ) ;
delete stream . connection . stream ;
var streamEvent = new StreamEvent _1 . StreamEvent ( true , publisher , 'streamDestroyed' , publisher . stream , 'unpublish' ) ;
publisher . emitEvent ( 'streamDestroyed' , [ streamEvent ] ) ;
2018-07-11 11:47:53 +02:00
streamEvent . callDefaultBehavior ( ) ;
2018-04-26 15:33:47 +02:00
}
} ;
2018-07-11 11:47:53 +02:00
/ * *
* Forces some user to leave the session
*
* # # # # Events dispatched
*
* The behavior is the same as when some user calls [ [ Session . disconnect ] ] , but ` reason ` property in all events will be ` "forceDisconnectByUser" ` .
*
* The [ [ Session ] ] object of every participant will dispatch a ` streamDestroyed ` event if the evicted user was publishing a stream , with property ` reason ` set to ` "forceDisconnectByUser" ` .
* The [ [ Session ] ] object of every participant except the evicted one will dispatch a ` connectionDestroyed ` event for the evicted user , with property ` reason ` set to ` "forceDisconnectByUser" ` .
*
* If any , the [ [ Publisher ] ] object of the evicted participant will also dispatch a ` streamDestroyed ` event with property ` reason ` set to ` "forceDisconnectByUser" ` .
* The [ [ Session ] ] object of the evicted participant will dispatch a ` sessionDisconnected ` event with property ` reason ` set to ` "forceDisconnectByUser" ` .
*
* See [ [ StreamEvent ] ] , [ [ ConnectionEvent ] ] and [ [ SessionDisconnectedEvent ] ] to learn more .
*
* @ returns A Promise ( to which you can optionally subscribe to ) that is resolved only after the participant has been successfully evicted from the session and rejected with an Error object if not
* /
Session . prototype . forceDisconnect = function ( connection ) {
var _this = this ;
return new Promise ( function ( resolve , reject ) {
console . info ( 'Forcing disconnect for connection ' + connection . connectionId ) ;
_this . openvidu . sendRequest ( 'forceDisconnect' , { connectionId : connection . connectionId } , function ( error , response ) {
if ( error ) {
console . error ( 'Error forcing disconnect for Connection ' + connection . connectionId , error ) ;
if ( error . code === 401 ) {
reject ( new OpenViduError _1 . OpenViduError ( OpenViduError _1 . OpenViduErrorName . OPENVIDU _PERMISSION _DENIED , "You don't have permissions to force a disconnection" ) ) ;
}
else {
reject ( error ) ;
}
}
else {
console . info ( 'Forcing disconnect correctly for Connection ' + connection . connectionId ) ;
resolve ( ) ;
}
} ) ;
} ) ;
} ;
/ * *
* Forces some user to unpublish a Stream
*
* # # # # Events dispatched
*
* The behavior is the same as when some user calls [ [ Session . unpublish ] ] , but ` reason ` property in all events will be ` "forceUnpublishByUser" `
*
* The [ [ Session ] ] object of every participant will dispatch a ` streamDestroyed ` event with property ` reason ` set to ` "forceDisconnectByUser" `
*
* The [ [ Publisher ] ] object of the affected participant will also dispatch a ` streamDestroyed ` event with property ` reason ` set to ` "forceDisconnectByUser" `
*
* See [ [ StreamEvent ] ] to learn more .
*
* @ returns A Promise ( to which you can optionally subscribe to ) that is resolved only after the remote Stream has been successfully unpublished from the session and rejected with an Error object if not
* /
Session . prototype . forceUnpublish = function ( stream ) {
var _this = this ;
return new Promise ( function ( resolve , reject ) {
console . info ( 'Forcing unpublish for stream ' + stream . streamId ) ;
_this . openvidu . sendRequest ( 'forceUnpublish' , { streamId : stream . streamId } , function ( error , response ) {
if ( error ) {
console . error ( 'Error forcing unpublish for Stream ' + stream . streamId , error ) ;
if ( error . code === 401 ) {
reject ( new OpenViduError _1 . OpenViduError ( OpenViduError _1 . OpenViduErrorName . OPENVIDU _PERMISSION _DENIED , "You don't have permissions to force an unpublishing" ) ) ;
}
else {
reject ( error ) ;
}
}
else {
console . info ( 'Forcing unpublish correctly for Stream ' + stream . streamId ) ;
resolve ( ) ;
}
} ) ;
} ) ;
} ;
2018-04-26 15:33:47 +02:00
/ * *
* Sends one signal . ` signal ` object has the following optional properties :
* ` ` ` json
* { data : string , to : Connection [ ] , type : string }
* ` ` `
* All users subscribed to that signal ( ` session.on('signal:type', ...) ` or ` session.on('signal', ...) ` for all signals ) and whose Connection objects are in ` to ` array will receive it . Their local
* Session objects will dispatch a ` signal ` or ` signal:type ` event . See [ [ SignalEvent ] ] to learn more .
*
* @ returns A Promise ( to which you can optionally subscribe to ) that is resolved if the message successfully reached openvidu - server and rejected with an Error object if not . _This doesn ' t
* mean that openvidu - server could resend the message to all the listed receivers . _
* /
/* tslint:disable:no-string-literal */
2018-05-08 10:40:46 +02:00
Session . prototype . signal = function ( signal ) {
2018-04-26 15:33:47 +02:00
var _this = this ;
2018-05-08 10:40:46 +02:00
return new Promise ( function ( resolve , reject ) {
2018-04-26 15:33:47 +02:00
var signalMessage = { } ;
if ( signal . to && signal . to . length > 0 ) {
var connectionIds _1 = [ ] ;
signal . to . forEach ( function ( connection ) {
connectionIds _1 . push ( connection . connectionId ) ;
} ) ;
signalMessage [ 'to' ] = connectionIds _1 ;
}
else {
signalMessage [ 'to' ] = [ ] ;
}
signalMessage [ 'data' ] = signal . data ? signal . data : '' ;
signalMessage [ 'type' ] = signal . type ? signal . type : '' ;
_this . openvidu . sendRequest ( 'sendMessage' , {
message : JSON . stringify ( signalMessage )
} , function ( error , response ) {
if ( ! ! error ) {
reject ( error ) ;
}
else {
resolve ( ) ;
}
} ) ;
2018-05-08 10:40:46 +02:00
} ) ;
2018-04-26 15:33:47 +02:00
} ;
/* tslint:enable:no-string-literal */
/ * *
* See [ [ EventDispatcher . on ] ]
* /
Session . prototype . on = function ( type , handler ) {
this . ee . on ( type , function ( event ) {
if ( event ) {
console . info ( "Event '" + type + "' triggered by 'Session'" , event ) ;
}
else {
console . info ( "Event '" + type + "' triggered by 'Session'" ) ;
}
handler ( event ) ;
} ) ;
if ( type === 'publisherStartSpeaking' || type === 'publisherStopSpeaking' ) {
this . speakingEventsEnabled = true ;
// If there are already available remote streams, enable hark 'speaking' event in all of them
for ( var connectionId in this . remoteConnections ) {
var str = this . remoteConnections [ connectionId ] . stream ;
if ( ! ! str && ! str . speechEvent && str . hasAudio ) {
str . enableSpeakingEvents ( ) ;
}
}
}
return this ;
} ;
/ * *
* See [ [ EventDispatcher . once ] ]
* /
Session . prototype . once = function ( type , handler ) {
this . ee . once ( type , function ( event ) {
if ( event ) {
console . info ( "Event '" + type + "' triggered by 'Session'" , event ) ;
}
else {
console . info ( "Event '" + type + "' triggered by 'Session'" ) ;
}
handler ( event ) ;
} ) ;
if ( type === 'publisherStartSpeaking' || type === 'publisherStopSpeaking' ) {
this . speakingEventsEnabled = true ;
// If there are already available remote streams, enable hark in all of them
for ( var connectionId in this . remoteConnections ) {
var str = this . remoteConnections [ connectionId ] . stream ;
if ( ! ! str && ! str . speechEvent && str . hasAudio ) {
str . enableOnceSpeakingEvents ( ) ;
}
}
}
return this ;
} ;
/ * *
* See [ [ EventDispatcher . off ] ]
* /
Session . prototype . off = function ( type , handler ) {
if ( ! handler ) {
this . ee . removeAllListeners ( type ) ;
}
else {
this . ee . off ( type , handler ) ;
}
if ( type === 'publisherStartSpeaking' || type === 'publisherStopSpeaking' ) {
this . speakingEventsEnabled = false ;
// If there are already available remote streams, disablae hark in all of them
for ( var connectionId in this . remoteConnections ) {
var str = this . remoteConnections [ connectionId ] . stream ;
if ( ! ! str && ! ! str . speechEvent ) {
str . disableSpeakingEvents ( ) ;
}
}
}
return this ;
} ;
/* Hidden methods */
/ * *
* @ hidden
* /
Session . prototype . onParticipantJoined = function ( response ) {
var _this = this ;
// Connection shouldn't exist
this . getConnection ( response . id , '' )
. then ( function ( connection ) {
console . warn ( 'Connection ' + response . id + ' already exists in connections list' ) ;
} ) [ "catch" ] ( function ( openViduError ) {
2018-05-08 13:01:34 +02:00
var connection = new Connection _1 . Connection ( _this , response ) ;
2018-04-26 15:33:47 +02:00
_this . remoteConnections [ response . id ] = connection ;
_this . ee . emitEvent ( 'connectionCreated' , [ new ConnectionEvent _1 . ConnectionEvent ( false , _this , 'connectionCreated' , connection , '' ) ] ) ;
} ) ;
} ;
/ * *
* @ hidden
* /
Session . prototype . onParticipantLeft = function ( msg ) {
var _this = this ;
2018-07-11 11:47:53 +02:00
this . getRemoteConnection ( msg . connectionId , 'Remote connection ' + msg . connectionId + " unknown when 'onParticipantLeft'. " +
2018-04-26 15:33:47 +02:00
'Existing remote connections: ' + JSON . stringify ( Object . keys ( this . remoteConnections ) ) )
. then ( function ( connection ) {
if ( ! ! connection . stream ) {
var stream = connection . stream ;
var streamEvent = new StreamEvent _1 . StreamEvent ( true , _this , 'streamDestroyed' , stream , msg . reason ) ;
_this . ee . emitEvent ( 'streamDestroyed' , [ streamEvent ] ) ;
2018-07-11 11:47:53 +02:00
streamEvent . callDefaultBehavior ( ) ;
2018-04-26 15:33:47 +02:00
delete _this . remoteStreamsCreated [ stream . streamId ] ;
}
delete _this . remoteConnections [ connection . connectionId ] ;
_this . ee . emitEvent ( 'connectionDestroyed' , [ new ConnectionEvent _1 . ConnectionEvent ( false , _this , 'connectionDestroyed' , connection , msg . reason ) ] ) ;
} ) [ "catch" ] ( function ( openViduError ) {
console . error ( openViduError ) ;
} ) ;
} ;
/ * *
* @ hidden
* /
Session . prototype . onParticipantPublished = function ( response ) {
var _this = this ;
var afterConnectionFound = function ( connection ) {
_this . remoteConnections [ connection . connectionId ] = connection ;
if ( ! _this . remoteStreamsCreated [ connection . stream . streamId ] ) {
// Avoid race condition between stream.subscribe() in "onParticipantPublished" and in "joinRoom" rpc callback
// This condition is false if openvidu-server sends "participantPublished" event to a subscriber participant that has
// already subscribed to certain stream in the callback of "joinRoom" method
_this . ee . emitEvent ( 'streamCreated' , [ new StreamEvent _1 . StreamEvent ( false , _this , 'streamCreated' , connection . stream , '' ) ] ) ;
}
_this . remoteStreamsCreated [ connection . stream . streamId ] = true ;
} ;
// Get the existing Connection created on 'onParticipantJoined' for
// existing participants or create a new one for new participants
var connection ;
this . getRemoteConnection ( response . id , "Remote connection '" + response . id + "' unknown when 'onParticipantPublished'. " +
'Existing remote connections: ' + JSON . stringify ( Object . keys ( this . remoteConnections ) ) )
. then ( function ( con ) {
// Update existing Connection
connection = con ;
response . metadata = con . data ;
connection . options = response ;
connection . initRemoteStreams ( response . streams ) ;
afterConnectionFound ( connection ) ;
} ) [ "catch" ] ( function ( openViduError ) {
// Create new Connection
2018-05-08 13:01:34 +02:00
connection = new Connection _1 . Connection ( _this , response ) ;
2018-04-26 15:33:47 +02:00
afterConnectionFound ( connection ) ;
} ) ;
} ;
/ * *
* @ hidden
* /
Session . prototype . onParticipantUnpublished = function ( msg ) {
var _this = this ;
2018-07-11 11:47:53 +02:00
if ( msg . connectionId === this . connection . connectionId ) {
// Your stream has been forcedly unpublished from the session
this . stopPublisherStream ( msg . reason ) ;
}
else {
this . getRemoteConnection ( msg . connectionId , "Remote connection '" + msg . connectionId + "' unknown when 'onParticipantUnpublished'. " +
'Existing remote connections: ' + JSON . stringify ( Object . keys ( this . remoteConnections ) ) )
. then ( function ( connection ) {
var streamEvent = new StreamEvent _1 . StreamEvent ( true , _this , 'streamDestroyed' , connection . stream , msg . reason ) ;
_this . ee . emitEvent ( 'streamDestroyed' , [ streamEvent ] ) ;
streamEvent . callDefaultBehavior ( ) ;
// Deleting the remote stream
var streamId = connection . stream . streamId ;
delete _this . remoteStreamsCreated [ streamId ] ;
connection . removeStream ( streamId ) ;
} ) [ "catch" ] ( function ( openViduError ) {
console . error ( openViduError ) ;
} ) ;
}
2018-04-26 15:33:47 +02:00
} ;
/ * *
* @ hidden
* /
Session . prototype . onParticipantEvicted = function ( msg ) {
2018-07-11 11:47:53 +02:00
if ( msg . connectionId === this . connection . connectionId ) {
// You have been evicted from the session
if ( ! ! this . sessionId && ! this . connection . disposed ) {
this . leave ( true , msg . reason ) ;
}
}
2018-04-26 15:33:47 +02:00
} ;
/ * *
* @ hidden
* /
Session . prototype . onNewMessage = function ( msg ) {
var _this = this ;
console . info ( 'New signal: ' + JSON . stringify ( msg ) ) ;
this . getConnection ( msg . from , "Connection '" + msg . from + "' unknow when 'onNewMessage'. Existing remote connections: "
+ JSON . stringify ( Object . keys ( this . remoteConnections ) ) + '. Existing local connection: ' + this . connection . connectionId )
. then ( function ( connection ) {
_this . ee . emitEvent ( 'signal' , [ new SignalEvent _1 . SignalEvent ( _this , msg . type , msg . data , connection ) ] ) ;
_this . ee . emitEvent ( 'signal:' + msg . type , [ new SignalEvent _1 . SignalEvent ( _this , msg . type , msg . data , connection ) ] ) ;
} ) [ "catch" ] ( function ( openViduError ) {
console . error ( openViduError ) ;
} ) ;
} ;
2018-07-11 11:47:53 +02:00
/ * *
* @ hidden
* /
Session . prototype . onStreamPropertyChanged = function ( msg ) {
var _this = this ;
this . getRemoteConnection ( msg . connectionId , 'Remote connection ' + msg . connectionId + " unknown when 'onStreamPropertyChanged'. " +
'Existing remote connections: ' + JSON . stringify ( Object . keys ( this . remoteConnections ) ) )
. then ( function ( connection ) {
if ( ! ! connection . stream && connection . stream . streamId === msg . streamId ) {
var stream = connection . stream ;
var oldValue = void 0 ;
switch ( msg . property ) {
case 'audioActive' :
oldValue = stream . audioActive ;
msg . newValue = msg . newValue === 'true' ;
stream . audioActive = msg . newValue ;
break ;
case 'videoActive' :
oldValue = stream . videoActive ;
msg . newValue = msg . newValue === 'true' ;
stream . videoActive = msg . newValue ;
break ;
case 'videoDimensions' :
oldValue = stream . videoDimensions ;
msg . newValue = JSON . parse ( JSON . parse ( msg . newValue ) ) ;
stream . videoDimensions = msg . newValue ;
break ;
}
_this . ee . emitEvent ( 'streamPropertyChanged' , [ new StreamPropertyChangedEvent _1 . StreamPropertyChangedEvent ( _this , stream , msg . property , msg . newValue , oldValue , msg . reason ) ] ) ;
stream . streamManager . emitEvent ( 'streamPropertyChanged' , [ new StreamPropertyChangedEvent _1 . StreamPropertyChangedEvent ( stream . streamManager , stream , msg . property , msg . newValue , oldValue , msg . reason ) ] ) ;
}
else {
console . error ( "No stream with streamId '" + msg . streamId + "' found for connection '" + msg . connectionId + "' on 'streamPropertyChanged' event" ) ;
}
} ) [ "catch" ] ( function ( openViduError ) {
console . error ( openViduError ) ;
} ) ;
} ;
2018-04-26 15:33:47 +02:00
/ * *
* @ hidden
* /
Session . prototype . recvIceCandidate = function ( msg ) {
var candidate = {
candidate : msg . candidate ,
sdpMid : msg . sdpMid ,
2018-06-27 16:29:31 +02:00
sdpMLineIndex : msg . sdpMLineIndex ,
toJSON : function ( ) {
return { candidate : msg . candidate } ;
}
2018-04-26 15:33:47 +02:00
} ;
this . getConnection ( msg . endpointName , 'Connection not found for endpoint ' + msg . endpointName + '. Ice candidate will be ignored: ' + candidate )
. then ( function ( connection ) {
var stream = connection . stream ;
2018-06-27 16:29:31 +02:00
stream . getWebRtcPeer ( ) . addIceCandidate ( candidate ) [ "catch" ] ( function ( error ) {
console . error ( 'Error adding candidate for ' + stream . streamId
+ ' stream of endpoint ' + msg . endpointName + ': ' + error ) ;
2018-04-26 15:33:47 +02:00
} ) ;
} ) [ "catch" ] ( function ( openViduError ) {
console . error ( openViduError ) ;
} ) ;
} ;
/ * *
* @ hidden
* /
Session . prototype . onSessionClosed = function ( msg ) {
console . info ( 'Session closed: ' + JSON . stringify ( msg ) ) ;
2018-07-11 11:47:53 +02:00
var s = msg . sessionId ;
2018-04-26 15:33:47 +02:00
if ( s !== undefined ) {
this . ee . emitEvent ( 'session-closed' , [ {
session : s
} ] ) ;
}
else {
console . warn ( 'Session undefined on session closed' , msg ) ;
}
} ;
/ * *
* @ hidden
* /
Session . prototype . onLostConnection = function ( ) {
2018-06-27 16:29:31 +02:00
/ * i f ( ! t h i s . c o n n e c t i o n ) {
2018-04-26 15:33:47 +02:00
console . warn ( 'Not connected to session: if you are not debugging, this is probably a certificate error' ) ;
2018-06-27 16:29:31 +02:00
const url = 'https://' + this . openvidu . getWsUri ( ) . split ( 'wss://' ) [ 1 ] . split ( '/openvidu' ) [ 0 ] ;
2018-04-26 15:33:47 +02:00
if ( window . confirm ( 'If you are not debugging, this is probably a certificate error at \"' + url + '\"\n\nClick OK to navigate and accept it' ) ) {
location . assign ( url + '/accept-certificate' ) ;
}
return ;
2018-06-27 16:29:31 +02:00
} * /
2018-04-26 15:33:47 +02:00
console . warn ( 'Lost connection in Session ' + this . sessionId ) ;
if ( ! ! this . sessionId && ! this . connection . disposed ) {
this . leave ( true , 'networkDisconnect' ) ;
}
} ;
2018-07-11 11:47:53 +02:00
/ * *
* @ hidden
* /
Session . prototype . onRecoveredConnection = function ( ) {
console . warn ( 'Recovered connection in Session ' + this . sessionId ) ;
this . ee . emitEvent ( 'connectionRecovered' , [ ] ) ;
} ;
2018-04-26 15:33:47 +02:00
/ * *
* @ hidden
* /
Session . prototype . onMediaError = function ( params ) {
console . error ( 'Media error: ' + JSON . stringify ( params ) ) ;
var err = params . error ;
if ( err ) {
this . ee . emitEvent ( 'error-media' , [ {
error : err
} ] ) ;
}
else {
console . warn ( 'Received undefined media error. Params:' , params ) ;
}
} ;
/ * *
* @ hidden
* /
Session . prototype . onRecordingStarted = function ( response ) {
this . ee . emitEvent ( 'recordingStarted' , [ new RecordingEvent _1 . RecordingEvent ( this , 'recordingStarted' , response . id , response . name ) ] ) ;
} ;
/ * *
* @ hidden
* /
Session . prototype . onRecordingStopped = function ( response ) {
this . ee . emitEvent ( 'recordingStopped' , [ new RecordingEvent _1 . RecordingEvent ( this , 'recordingStopped' , response . id , response . name ) ] ) ;
} ;
/ * *
* @ hidden
* /
Session . prototype . emitEvent = function ( type , eventArray ) {
this . ee . emitEvent ( type , eventArray ) ;
} ;
/ * *
* @ hidden
* /
Session . prototype . leave = function ( forced , reason ) {
var _this = this ;
forced = ! ! forced ;
console . info ( 'Leaving Session (forced=' + forced + ')' ) ;
2018-05-03 11:48:57 +02:00
if ( ! ! this . connection ) {
if ( ! this . connection . disposed && ! forced ) {
this . openvidu . sendRequest ( 'leaveRoom' , function ( error , response ) {
if ( error ) {
console . error ( error ) ;
}
_this . openvidu . closeWs ( ) ;
} ) ;
}
else {
this . openvidu . closeWs ( ) ;
}
2018-07-11 11:47:53 +02:00
this . stopPublisherStream ( reason ) ;
2018-05-03 11:48:57 +02:00
if ( ! this . connection . disposed ) {
// Make Session object dispatch 'sessionDisconnected' event (if it is not already disposed)
var sessionDisconnectEvent = new SessionDisconnectedEvent _1 . SessionDisconnectedEvent ( this , reason ) ;
this . ee . emitEvent ( 'sessionDisconnected' , [ sessionDisconnectEvent ] ) ;
2018-07-11 11:47:53 +02:00
sessionDisconnectEvent . callDefaultBehavior ( ) ;
2018-05-03 11:48:57 +02:00
}
2018-04-26 15:33:47 +02:00
}
else {
2018-05-03 11:48:57 +02:00
console . warn ( 'You were not connected to the session ' + this . sessionId ) ;
2018-04-26 15:33:47 +02:00
}
} ;
/* Private methods */
Session . prototype . connectAux = function ( token ) {
var _this = this ;
return new Promise ( function ( resolve , reject ) {
_this . openvidu . startWs ( function ( error ) {
if ( ! ! error ) {
reject ( error ) ;
}
else {
var joinParams = {
token : ( ! ! token ) ? token : '' ,
session : _this . sessionId ,
metadata : ! ! _this . options . metadata ? _this . options . metadata : '' ,
secret : _this . openvidu . getSecret ( ) ,
recorder : _this . openvidu . getRecorder ( )
} ;
_this . openvidu . sendRequest ( 'joinRoom' , joinParams , function ( error , response ) {
2018-05-03 11:48:57 +02:00
if ( ! ! error ) {
reject ( error ) ;
}
else {
2018-07-11 11:47:53 +02:00
// Initialize capabilities object with the role
_this . capabilities = {
subscribe : true ,
publish : _this . openvidu . role !== 'SUBSCRIBER' ,
forceUnpublish : _this . openvidu . role === 'MODERATOR' ,
forceDisconnect : _this . openvidu . role === 'MODERATOR'
} ;
2018-05-03 11:48:57 +02:00
// Initialize local Connection object with values returned by openvidu-server
2018-05-08 13:01:34 +02:00
_this . connection = new Connection _1 . Connection ( _this ) ;
2018-05-03 11:48:57 +02:00
_this . connection . connectionId = response . id ;
_this . connection . data = response . metadata ;
// Initialize remote Connections with value returned by openvidu-server
var events _1 = {
connections : new Array ( ) ,
streams : new Array ( )
} ;
var existingParticipants = response . value ;
existingParticipants . forEach ( function ( participant ) {
2018-05-08 13:01:34 +02:00
var connection = new Connection _1 . Connection ( _this , participant ) ;
2018-05-03 11:48:57 +02:00
_this . remoteConnections [ connection . connectionId ] = connection ;
events _1 . connections . push ( connection ) ;
if ( ! ! connection . stream ) {
_this . remoteStreamsCreated [ connection . stream . streamId ] = true ;
events _1 . streams . push ( connection . stream ) ;
}
} ) ;
// Own 'connectionCreated' event
_this . ee . emitEvent ( 'connectionCreated' , [ new ConnectionEvent _1 . ConnectionEvent ( false , _this , 'connectionCreated' , _this . connection , '' ) ] ) ;
// One 'connectionCreated' event for each existing connection in the session
events _1 . connections . forEach ( function ( connection ) {
_this . ee . emitEvent ( 'connectionCreated' , [ new ConnectionEvent _1 . ConnectionEvent ( false , _this , 'connectionCreated' , connection , '' ) ] ) ;
} ) ;
// One 'streamCreated' event for each active stream in the session
events _1 . streams . forEach ( function ( stream ) {
_this . ee . emitEvent ( 'streamCreated' , [ new StreamEvent _1 . StreamEvent ( false , _this , 'streamCreated' , stream , '' ) ] ) ;
} ) ;
resolve ( ) ;
}
2018-04-26 15:33:47 +02:00
} ) ;
}
} ) ;
} ) ;
} ;
2018-07-11 11:47:53 +02:00
Session . prototype . stopPublisherStream = function ( reason ) {
if ( ! ! this . connection . stream ) {
// Dispose Publisher's local stream
this . connection . stream . disposeWebRtcPeer ( ) ;
if ( this . connection . stream . isLocalStreamPublished ) {
// Make Publisher object dispatch 'streamDestroyed' event if the Stream was published
this . connection . stream . ee . emitEvent ( 'local-stream-destroyed' , [ reason ] ) ;
}
}
} ;
2018-04-26 15:33:47 +02:00
Session . prototype . stringClientMetadata = function ( metadata ) {
if ( typeof metadata !== 'string' ) {
return JSON . stringify ( metadata ) ;
}
else {
return metadata ;
}
} ;
Session . prototype . getConnection = function ( connectionId , errorMessage ) {
var _this = this ;
return new Promise ( function ( resolve , reject ) {
var connection = _this . remoteConnections [ connectionId ] ;
if ( ! ! connection ) {
// Resolve remote connection
resolve ( connection ) ;
}
else {
if ( _this . connection . connectionId === connectionId ) {
// Resolve local connection
resolve ( _this . connection ) ;
}
else {
// Connection not found. Reject with OpenViduError
reject ( new OpenViduError _1 . OpenViduError ( OpenViduError _1 . OpenViduErrorName . GENERIC _ERROR , errorMessage ) ) ;
}
}
} ) ;
} ;
Session . prototype . getRemoteConnection = function ( connectionId , errorMessage ) {
var _this = this ;
return new Promise ( function ( resolve , reject ) {
var connection = _this . remoteConnections [ connectionId ] ;
if ( ! ! connection ) {
// Resolve remote connection
resolve ( connection ) ;
}
else {
// Remote connection not found. Reject with OpenViduError
reject ( new OpenViduError _1 . OpenViduError ( OpenViduError _1 . OpenViduErrorName . GENERIC _ERROR , errorMessage ) ) ;
}
} ) ;
} ;
2018-05-03 11:48:57 +02:00
Session . prototype . processToken = function ( token ) {
var url = new URL ( token ) ;
this . sessionId = url . searchParams . get ( 'sessionId' ) ;
var secret = url . searchParams . get ( 'secret' ) ;
var recorder = url . searchParams . get ( 'recorder' ) ;
2018-06-27 16:29:31 +02:00
var turnUsername = url . searchParams . get ( 'turnUsername' ) ;
var turnCredential = url . searchParams . get ( 'turnCredential' ) ;
var role = url . searchParams . get ( 'role' ) ;
2018-05-03 11:48:57 +02:00
if ( ! ! secret ) {
this . openvidu . secret = secret ;
}
if ( ! ! recorder ) {
this . openvidu . recorder = true ;
}
2018-06-27 16:29:31 +02:00
if ( ! ! turnUsername && ! ! turnCredential ) {
var stunUrl = 'stun:' + url . hostname + ':3478' ;
var turnUrl1 = 'turn:' + url . hostname + ':3478' ;
var turnUrl2 = turnUrl1 + '?transport=tcp' ;
this . openvidu . iceServers = [
{ urls : [ stunUrl ] } ,
{ urls : [ turnUrl1 , turnUrl2 ] , username : turnUsername , credential : turnCredential }
] ;
console . log ( 'TURN temp credentials [' + turnUsername + ':' + turnCredential + ']' ) ;
}
if ( ! ! role ) {
this . openvidu . role = role ;
}
2018-05-03 11:48:57 +02:00
this . openvidu . wsUri = 'wss://' + url . host + '/openvidu' ;
} ;
2018-04-26 15:33:47 +02:00
return Session ;
} ( ) ) ;
exports . Session = Session ;
//# sourceMappingURL=Session.js.map