fix: fix player living in room bug
This commit is contained in:
parent
e560f071ad
commit
34930fc6ae
@ -263,5 +263,6 @@ public class ChessController {
|
||||
.filter(e -> e.getValue().getLastStateChange().toInstant().isBefore(before10Min))
|
||||
.map(Map.Entry::getKey)
|
||||
.forEach(rooms::remove);
|
||||
rooms.values().forEach(Room::tryClean);
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +196,19 @@ public class Room {
|
||||
return sessionId.equals(whiteSession.getId());
|
||||
}
|
||||
|
||||
public void tryClean() {
|
||||
if (whiteSession != null) {
|
||||
if (!whiteSession.isOpen()) {
|
||||
this.leave(whiteSession);
|
||||
}
|
||||
}
|
||||
if (blackSession != null) {
|
||||
if (!blackSession.isOpen()) {
|
||||
this.leave(blackSession);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum RoomState {
|
||||
CREATED,
|
||||
WAITING,
|
||||
|
Loading…
x
Reference in New Issue
Block a user