* Changed table maneger to remove chat sessions that were never removed. Minor formattings.

This commit is contained in:
LevelX2 2014-07-25 15:54:51 +02:00
parent 8bdc94082d
commit e25a60b312
5 changed files with 18 additions and 11 deletions

View file

@ -299,7 +299,7 @@ public class TableWaitingDialog extends MageDialog {
}
class TableWaitModel extends AbstractTableModel {
private String[] columnNames = new String[]{"Seat Num", "Player Name", "Player Type"};
private final String[] columnNames = new String[]{"Seat Num", "Player Name", "Player Type"};
private SeatView[] seats = new SeatView[0];
public void loadData(TableView table) {
@ -362,10 +362,10 @@ class TableWaitModel extends AbstractTableModel {
class UpdateSeatsTask extends SwingWorker<Void, TableView> {
private Session session;
private UUID roomId;
private UUID tableId;
private TableWaitingDialog dialog;
private final Session session;
private final UUID roomId;
private final UUID tableId;
private final TableWaitingDialog dialog;
private int count = 0;
private static final Logger logger = Logger.getLogger(TableWaitingDialog.class);

View file

@ -69,7 +69,9 @@ public class ChatManager {
}
public void destroyChatSession(UUID chatId) {
chatSessions.remove(chatId);
if (chatId != null) {
chatSessions.remove(chatId);
}
}
public void broadcast(UUID chatId, String userName, String message, MessageColor color) {

View file

@ -204,7 +204,8 @@ public class TableManager {
public boolean removeTable(UUID userId, UUID tableId) {
if (isTableOwner(tableId, userId) || UserManager.getInstance().isAdmin(userId)) {
leaveTable(userId, tableId);
leaveTable(userId, tableId);
ChatManager.getInstance().destroyChatSession(controllers.get(tableId).getChatId());
removeTable(tableId);
return true;
}
@ -246,6 +247,8 @@ public class TableManager {
public void startMatch(UUID userId, UUID roomId, UUID tableId) {
if (controllers.containsKey(tableId)) {
controllers.get(tableId).startMatch(userId);
// chat of start dialog can be killed
ChatManager.getInstance().destroyChatSession(controllers.get(tableId).getChatId());
}
}
@ -264,6 +267,7 @@ public class TableManager {
public void startTournament(UUID userId, UUID roomId, UUID tableId) {
if (controllers.containsKey(tableId)) {
controllers.get(tableId).startTournament(userId);
ChatManager.getInstance().destroyChatSession(controllers.get(tableId).getChatId());
}
}
@ -334,9 +338,10 @@ public class TableManager {
public void removeTable(UUID tableId) {
if (tables.containsKey(tableId)) {
Table table = tables.get(tableId);
ChatManager.getInstance().destroyChatSession(controllers.get(tableId).getChatId());
controllers.remove(tableId);
tables.remove(tableId);
// If table is not finished, the table has to removed completly (if finished it will be removed in GamesRoomImpl.Update())
// If table is not finished, the table has to be removed completly (if finished it will be removed in GamesRoomImpl.Update())
if (!table.getState().equals(TableState.FINISHED)) {
GamesRoomManager.getInstance().removeTable(tableId);
}

View file

@ -40,8 +40,8 @@ public class GamesRoomManager {
private static final GamesRoomManager INSTANCE = new GamesRoomManager();
// private static final Logger logger = Logger.getLogger(GamesRoomManager.class);
private ConcurrentHashMap<UUID, GamesRoom> rooms = new ConcurrentHashMap<UUID, GamesRoom>();
private UUID mainRoomId;
private final ConcurrentHashMap<UUID, GamesRoom> rooms = new ConcurrentHashMap<>();
private final UUID mainRoomId;
public static GamesRoomManager getInstance() {
return INSTANCE;

View file

@ -70,7 +70,7 @@ public abstract class ContinuousRuleModifiyingEffectImpl extends ContinuousEffec
@Override
public String getInfoMessage(Ability source, Game game) {
if (infoMessage == null) {
String message = null;
String message;
MageObject object = game.getObject(source.getSourceId());
if (object != null) {
message = source.getRule(object.getLogName());