Better handling of reconnect. Clear the state properly and handle spotlights.

auto_join_3.3
Håvar Aambø Fosstveit 2020-05-08 22:01:28 +02:00
parent d09e7f5565
commit 717c0053e5
8 changed files with 49 additions and 13 deletions

View File

@ -940,14 +940,10 @@ export default class RoomClient
{ {
if (consumer.kind === 'video') if (consumer.kind === 'video')
{ {
if (spotlights.indexOf(consumer.appData.peerId) > -1) if (spotlights.includes(consumer.appData.peerId))
{
await this._resumeConsumer(consumer); await this._resumeConsumer(consumer);
}
else else
{
await this._pauseConsumer(consumer); await this._pauseConsumer(consumer);
}
} }
} }
} }
@ -1516,9 +1512,7 @@ export default class RoomClient
if (consumer.appData.peerId === peerId && consumer.appData.source === type) if (consumer.appData.peerId === peerId && consumer.appData.source === type)
{ {
if (mute) if (mute)
{
await this._pauseConsumer(consumer); await this._pauseConsumer(consumer);
}
else else
await this._resumeConsumer(consumer); await this._resumeConsumer(consumer);
} }
@ -1846,6 +1840,11 @@ export default class RoomClient
this._recvTransport = null; this._recvTransport = null;
} }
this._spotlights.clearSpotlights();
store.dispatch(peerActions.clearPeers());
store.dispatch(consumerActions.clearConsumers());
store.dispatch(roomActions.clearSpotlights());
store.dispatch(roomActions.setRoomState('connecting')); store.dispatch(roomActions.setRoomState('connecting'));
}); });
@ -2561,8 +2560,6 @@ export default class RoomClient
case 'moderator:mute': case 'moderator:mute':
{ {
// const { peerId } = notification.data;
if (this._micProducer && !this._micProducer.paused) if (this._micProducer && !this._micProducer.paused)
{ {
this.muteMic(); this.muteMic();
@ -2581,8 +2578,6 @@ export default class RoomClient
case 'moderator:stopVideo': case 'moderator:stopVideo':
{ {
// const { peerId } = notification.data;
this.disableWebcam(); this.disableWebcam();
this.disableScreenSharing(); this.disableScreenSharing();

View File

@ -95,6 +95,15 @@ export default class Spotlights extends EventEmitter
}); });
} }
clearSpotlights()
{
this._started = false;
this._peerList = [];
this._selectedSpotlights = [];
this._currentSpotlights = [];
}
_newPeer(id) _newPeer(id)
{ {
logger.debug( logger.debug(

View File

@ -10,6 +10,11 @@ export const removeConsumer = (consumerId, peerId) =>
payload : { consumerId, peerId } payload : { consumerId, peerId }
}); });
export const clearConsumers = () =>
({
type : 'CLEAR_CONSUMERS'
});
export const setConsumerPaused = (consumerId, originator) => export const setConsumerPaused = (consumerId, originator) =>
({ ({
type : 'SET_CONSUMER_PAUSED', type : 'SET_CONSUMER_PAUSED',

View File

@ -10,6 +10,11 @@ export const removePeer = (peerId) =>
payload : { peerId } payload : { peerId }
}); });
export const clearPeers = () =>
({
type : 'CLEAR_PEERS'
});
export const setPeerDisplayName = (displayName, peerId) => export const setPeerDisplayName = (displayName, peerId) =>
({ ({
type : 'SET_PEER_DISPLAY_NAME', type : 'SET_PEER_DISPLAY_NAME',

View File

@ -130,6 +130,11 @@ export const setSpotlights = (spotlights) =>
payload : { spotlights } payload : { spotlights }
}); });
export const clearSpotlights = () =>
({
type : 'CLEAR_SPOTLIGHTS'
});
export const toggleJoined = () => export const toggleJoined = () =>
({ ({
type : 'TOGGLE_JOINED' type : 'TOGGLE_JOINED'

View File

@ -110,6 +110,11 @@ const consumers = (state = initialState, action) =>
return { ...state, [consumerId]: newConsumer }; return { ...state, [consumerId]: newConsumer };
} }
case 'CLEAR_CONSUMERS':
{
return initialState;
}
default: default:
return state; return state;
} }

View File

@ -1,4 +1,6 @@
const peer = (state = {}, action) => const initialState = {};
const peer = (state = initialState, action) =>
{ {
switch (action.type) switch (action.type)
{ {
@ -85,7 +87,7 @@ const peer = (state = {}, action) =>
} }
}; };
const peers = (state = {}, action) => const peers = (state = initialState, action) =>
{ {
switch (action.type) switch (action.type)
{ {
@ -139,6 +141,11 @@ const peers = (state = {}, action) =>
return { ...state, [oldPeer.id]: peer(oldPeer, action) }; return { ...state, [oldPeer.id]: peer(oldPeer, action) };
} }
case 'CLEAR_PEERS':
{
return initialState;
}
default: default:
return state; return state;
} }

View File

@ -212,6 +212,11 @@ const room = (state = initialState, action) =>
return { ...state, spotlights }; return { ...state, spotlights };
} }
case 'CLEAR_SPOTLIGHTS':
{
return { ...state, spotlights: [] };
}
case 'SET_LOBBY_PEERS_PROMOTION_IN_PROGRESS': case 'SET_LOBBY_PEERS_PROMOTION_IN_PROGRESS':
return { ...state, lobbyPeersPromotionInProgress: action.payload.flag }; return { ...state, lobbyPeersPromotionInProgress: action.payload.flag };