Fix - old draft chat rooms are now destroyed automatically by chat server during cleanup instead of manually by tournament
This commit is contained in:
@@ -66,6 +66,10 @@ public class ChatRoom {
|
||||
}
|
||||
}
|
||||
|
||||
public long getSecsSinceLastMessage() {
|
||||
return (System.currentTimeMillis() - _lastMessages.getLast().getWhen().getTime()) / 1000;
|
||||
}
|
||||
|
||||
private void shrinkLastMessages() {
|
||||
while (_lastMessages.size() > MAX_MESSAGE_HISTORY_COUNT) {
|
||||
_lastMessages.removeFirst();
|
||||
|
||||
@@ -189,4 +189,8 @@ public class ChatRoomMediator {
|
||||
_lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public long getSecsSinceLastMessage() {
|
||||
return _chatRoom.getSecsSinceLastMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.gempukku.lotro.PrivateInformationException;
|
||||
import com.gempukku.lotro.db.IgnoreDAO;
|
||||
import com.gempukku.lotro.db.PlayerDAO;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -72,6 +73,20 @@ public class ChatServer extends AbstractServer {
|
||||
}
|
||||
|
||||
protected void cleanup() {
|
||||
// remove draft chat rooms if they are unused
|
||||
Set<String> toRemove = new HashSet<>();
|
||||
_chatRooms.forEach((roomName, chatRoomMediator) -> {
|
||||
if (roomName.startsWith("Draft-")
|
||||
&& chatRoomMediator.getUsersInRoom(true).size() == 0
|
||||
&& chatRoomMediator.getSecsSinceLastMessage() > 5 * 60) {
|
||||
|
||||
// empty draft chat room without any messages sends in last 45 minutes
|
||||
toRemove.add(roomName);
|
||||
}
|
||||
});
|
||||
|
||||
toRemove.forEach(this::destroyChatRoom);
|
||||
|
||||
for (ChatRoomMediator chatRoomMediator : _chatRooms.values())
|
||||
chatRoomMediator.cleanup();
|
||||
}
|
||||
|
||||
@@ -199,10 +199,6 @@ public class TableDraftTournament extends BaseTournament implements Tournament {
|
||||
_tournamentInfo.Stage = Stage.PLAYING_GAMES;
|
||||
_tournamentService.recordTournamentStage(_tournamentId, getTournamentStage());
|
||||
} else if (getTournamentStage() == Stage.PLAYING_GAMES) {
|
||||
|
||||
// Chat room no longer needed - kept alive during deck-building if people stayed longer
|
||||
chatServer.destroyChatRoom("Draft-" + tableDraftInfo.tableDraftParams.tournamentId);
|
||||
|
||||
if (_currentlyPlayingPlayers.isEmpty()) {
|
||||
if (_tournamentInfo.PairingMechanism.isFinished(getCurrentRound(), _players, _droppedPlayers)) {
|
||||
result.add(finishTournament(collectionsManager));
|
||||
|
||||
Reference in New Issue
Block a user