@ -26,6 +26,7 @@ import {
toggleAudioOnly
} from './actions' ;
import {
CONFERENCE _FAILED ,
CONFERENCE _JOINED ,
DATA _CHANNEL _OPENED ,
SET _AUDIO _ONLY ,
@ -55,6 +56,9 @@ MiddlewareRegistry.register(store => next => action => {
case CONNECTION _ESTABLISHED :
return _connectionEstablished ( store , next , action ) ;
case CONFERENCE _FAILED :
return _conferenceFailed ( next , action ) ;
case CONFERENCE _JOINED :
return _conferenceJoined ( store , next , action ) ;
@ -109,6 +113,33 @@ function _connectionEstablished({ dispatch }, next, action) {
return result ;
}
/ * *
* Makes sure to leave a failed conference in order to release any allocated
* resources like peerconnections , emit participant left events etc .
*
* @ param { Dispatch } next - The redux dispatch function to dispatch the
* specified action to the specified store .
* @ param { Action } action - The redux action CONFERENCE _FAILED which is being
* dispatched in the specified store .
* @ private
* @ returns { Object } The value returned by { @ code next ( action ) } .
* /
function _conferenceFailed ( next , action ) {
const result = next ( action ) ;
const { conference , error } = action ;
! error . recoverable
&& conference
&& conference . leave ( ) . catch ( leaveError => {
// Even though we don't care too much about the failure it may be
// good to now that it happen, so log it on the info level.
logger . info (
'There was an error leaving a failed conference: ' , leaveError ) ;
} ) ;
return result ;
}
/ * *
* Does extra sync up on properties that may need to be updated after the
* conference was joined .