Protect against late PARTICIPANT_JOINED

Like the preceding commit "ref(base/conference): clear the 'conference'
field on WILL_LEAVE", this commit is part of the story how we are to
deal with conferences which take noticeable time to leave.

If a leave is delayed and the leaving JitsiConference manages to sneak a
PARTICIPANT_JOINED in, it may create a remote participant who even
collides with the local participant.
This commit is contained in:
Lyubo Marinov 2018-05-27 19:13:26 -05:00 committed by Saúl Ibarra Corretgé
parent fa9549582f
commit 8cfc83f18c
1 changed files with 30 additions and 4 deletions

View File

@ -235,14 +235,40 @@ export function participantDisplayNameChanged(id, displayName = '') {
* }} * }}
*/ */
export function participantJoined(participant) { export function participantJoined(participant) {
if (!participant.local && !participant.conference) { // Only the local participant is not identified with an id-conference pair.
if (participant.local) {
return {
type: PARTICIPANT_JOINED,
participant
};
}
// In other words, a remote participant is identified with an id-conference
// pair.
const { conference } = participant;
if (!conference) {
throw Error( throw Error(
'A remote participant must be associated with a JitsiConference!'); 'A remote participant must be associated with a JitsiConference!');
} }
return { return (dispatch, getState) => {
// A remote participant is only expected to join in a joined or joining
// conference. The following check is really necessary because a
// JitsiConference may have moved into leaving but may still manage to
// sneak a PARTICIPANT_JOINED in if its leave is delayed for any purpose
// (which is not outragous given that leaving involves network
// requests.)
const stateFeaturesBaseConference
= getState()['features/base/conference'];
if (conference === stateFeaturesBaseConference.conference
|| conference === stateFeaturesBaseConference.joining) {
return dispatch({
type: PARTICIPANT_JOINED, type: PARTICIPANT_JOINED,
participant participant
});
}
}; };
} }