Clear presence only if the connection’s displacement listener is still present

This commit is contained in:
Chris Eager
2023-09-18 16:39:37 -05:00
committed by Chris Eager
parent 407070c9fc
commit 8c7975d89a
2 changed files with 7 additions and 3 deletions

View File

@@ -235,11 +235,12 @@ public class ClientPresenceManager extends RedisClusterPubSubAdapter<String, Str
public boolean clearPresence(final UUID accountUuid, final long deviceId, final DisplacedPresenceListener listener) {
final String presenceKey = getPresenceKey(accountUuid, deviceId);
if (!displacementListenersByPresenceKey.remove(presenceKey, listener)) {
if (displacementListenersByPresenceKey.remove(presenceKey, listener)) {
return clearPresence(presenceKey);
} else {
displacementListenerAlreadyRemovedCounter.increment();
return false;
}
return clearPresence(presenceKey);
}
private boolean clearPresence(final String presenceKey) {