mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
Merge pull request #494 from Flowdalic/mux-race-condition
[muc] Check for self-presence first
This commit is contained in:
commit
2ff53abef3
1 changed files with 14 additions and 11 deletions
|
@ -212,7 +212,12 @@ public class MultiUserChat {
|
||||||
switch (presence.getType()) {
|
switch (presence.getType()) {
|
||||||
case available:
|
case available:
|
||||||
Presence oldPresence = occupantsMap.put(from, presence);
|
Presence oldPresence = occupantsMap.put(from, presence);
|
||||||
if (oldPresence != null) {
|
if (mucUser.getStatus().contains(MUCUser.Status.PRESENCE_TO_SELF_110)) {
|
||||||
|
processedReflectedSelfPresence = true;
|
||||||
|
synchronized (this) {
|
||||||
|
notify();
|
||||||
|
}
|
||||||
|
} else if (oldPresence != null) {
|
||||||
// Get the previous occupant's affiliation & role
|
// Get the previous occupant's affiliation & role
|
||||||
MUCUser mucExtension = MUCUser.from(oldPresence);
|
MUCUser mucExtension = MUCUser.from(oldPresence);
|
||||||
MUCAffiliation oldAffiliation = mucExtension.getItem().getAffiliation();
|
MUCAffiliation oldAffiliation = mucExtension.getItem().getAffiliation();
|
||||||
|
@ -228,11 +233,6 @@ public class MultiUserChat {
|
||||||
newAffiliation,
|
newAffiliation,
|
||||||
isUserStatusModification,
|
isUserStatusModification,
|
||||||
from);
|
from);
|
||||||
} else if (mucUser.getStatus().contains(MUCUser.Status.PRESENCE_TO_SELF_110)) {
|
|
||||||
processedReflectedSelfPresence = true;
|
|
||||||
synchronized (this) {
|
|
||||||
notify();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// A new occupant has joined the room
|
// A new occupant has joined the room
|
||||||
for (ParticipantStatusListener listener : participantStatusListeners) {
|
for (ParticipantStatusListener listener : participantStatusListeners) {
|
||||||
|
@ -789,11 +789,14 @@ public class MultiUserChat {
|
||||||
|
|
||||||
StanzaFilter reflectedLeavePresenceFilter = new AndFilter(reflectedLeavePresenceFilters);
|
StanzaFilter reflectedLeavePresenceFilter = new AndFilter(reflectedLeavePresenceFilters);
|
||||||
|
|
||||||
// Reset occupant information first so that we are assume that we left the room even if sendStanza() would
|
Presence reflectedLeavePresence;
|
||||||
// throw.
|
try {
|
||||||
|
reflectedLeavePresence = connection.createStanzaCollectorAndSend(reflectedLeavePresenceFilter, leavePresence).nextResultOrThrow();
|
||||||
|
} finally {
|
||||||
|
// Reset occupant information after we send the leave presence. This ensures that we only call userHasLeft()
|
||||||
|
// and reset the local MUC state after we successfully left the MUC (or if an exception occurred).
|
||||||
userHasLeft();
|
userHasLeft();
|
||||||
|
}
|
||||||
Presence reflectedLeavePresence = connection.createStanzaCollectorAndSend(reflectedLeavePresenceFilter, leavePresence).nextResultOrThrow();
|
|
||||||
|
|
||||||
return reflectedLeavePresence;
|
return reflectedLeavePresence;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue