@ -161,6 +161,17 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u
} ;
} ;
WebRTC . prototype . receivedRoom = function ( event , room ) {
WebRTC . prototype . receivedRoom = function ( event , room ) {
if ( this . currentroom && room && this . currentroom . Name == room . Name ) {
// No room change, usually happens on reconnect.
var ids = this . conference . getDisconnectedIds ( ) ;
if ( ids . length > 1 && this . conference . id ) {
// User was in a conference before, try to re-establish.
console . log ( "Re-establishing conference" , this . conference . id , ids ) ;
this . conference . pushUpdate ( true ) ;
}
return ;
}
if ( this . isConferenceRoom ( ) ) {
if ( this . isConferenceRoom ( ) ) {
// Switching from a conference room closes all current connections.
// Switching from a conference room closes all current connections.
_ . defer ( _ . bind ( function ( ) {
_ . defer ( _ . bind ( function ( ) {
@ -288,7 +299,7 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u
// Clean own internal data before feeding into browser.
// Clean own internal data before feeding into browser.
delete data . _conference ;
delete data . _conference ;
autoaccept = true ;
autoaccept = true ;
} else if ( this . conference . hasCalls ( ) ) {
} else if ( this . conference . hasCalls ( ) && ! this . conference . isDisconnected ( from ) ) {
// TODO(fancycode): support joining callers to currently active conference.
// TODO(fancycode): support joining callers to currently active conference.
console . warn ( "Received Offer while already in a call -> busy." , from ) ;
console . warn ( "Received Offer while already in a call -> busy." , from ) ;
this . api . sendBye ( from , "busy" ) ;
this . api . sendBye ( from , "busy" ) ;
@ -360,8 +371,11 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u
console . warn ( "Received Conference for unknown call -> ignore." , to , data ) ;
console . warn ( "Received Conference for unknown call -> ignore." , to , data ) ;
return ;
return ;
} else if ( ids . length == 1 ) {
} else if ( ids . length == 1 ) {
// Peer-to-peer call will be upgraded to conference.
// Peer-to-peer call will be upgraded to conference. Only is allowed
if ( data . indexOf ( ids [ 0 ] ) === - 1 ) {
// if currently active call is in the list of conference participants
// and the "Conference" is received from him. Upgrading is always
// allowed for server-managed conference rooms.
if ( ( from !== ids [ 0 ] || data . indexOf ( ids [ 0 ] ) === - 1 ) && ! this . isConferenceRoom ( ) ) {
console . warn ( "Received Conference for unknown call -> ignore." , to , data ) ;
console . warn ( "Received Conference for unknown call -> ignore." , to , data ) ;
return ;
return ;
}
}
@ -450,6 +464,14 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u
call . e . on ( "closed" , _ . bind ( function ( ) {
call . e . on ( "closed" , _ . bind ( function ( ) {
this . conference . removeCall ( id ) ;
this . conference . removeCall ( id ) ;
} , this ) ) ;
} , this ) ) ;
call . e . on ( "connectionStateChange" , _ . bind ( function ( event , state , currentcall ) {
switch ( state ) {
case "disconnected" :
case "failed" :
this . conference . markDisconnected ( currentcall . id ) ;
break ;
}
} , this ) ) ;
return call ;
return call ;
} ;
} ;
@ -755,6 +777,8 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u
} , this ) ) ;
} , this ) ) ;
this . stop ( ) ;
this . stop ( ) ;
} else if ( calls . length === 1 ) {
} else if ( calls . length === 1 ) {
// Downgraded to peer-to-peer again.
this . conference . id = null ;
this . e . triggerHandler ( "peerconference" , [ null ] ) ;
this . e . triggerHandler ( "peerconference" , [ null ] ) ;
this . e . triggerHandler ( "peercall" , [ calls [ 0 ] ] ) ;
this . e . triggerHandler ( "peercall" , [ calls [ 0 ] ] ) ;
}
}