mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Merge branch 'master' of https://github.com/magefree/mage
This commit is contained in:
commit
05426f7dec
5 changed files with 38 additions and 12 deletions
|
@ -712,7 +712,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
connection.setShowAbilityPickerForced(showAbilityPickerForced);
|
connection.setShowAbilityPickerForced(showAbilityPickerForced);
|
||||||
logger.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername);
|
logger.debug("connecting (auto): " + proxyType + " " + proxyServer + " " + proxyPort + " " + proxyUsername);
|
||||||
if (MageFrame.connect(connection)) {
|
if (MageFrame.connect(connection)) {
|
||||||
showGames();
|
showGames(false);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
showMessage("Unable to connect to server");
|
showMessage("Unable to connect to server");
|
||||||
|
@ -888,7 +888,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
}//GEN-LAST:event_btnDeckEditorActionPerformed
|
}//GEN-LAST:event_btnDeckEditorActionPerformed
|
||||||
|
|
||||||
private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed
|
private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed
|
||||||
this.showGames();
|
this.showGames(true);
|
||||||
}//GEN-LAST:event_btnGamesActionPerformed
|
}//GEN-LAST:event_btnGamesActionPerformed
|
||||||
|
|
||||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
||||||
|
@ -970,10 +970,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
this.tablesPane.hideTables();
|
this.tablesPane.hideTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showGames() {
|
public void showGames(boolean setActive) {
|
||||||
|
MagePane topPane = getTopMost(tablesPane);
|
||||||
this.tablesPane.setVisible(true);
|
this.tablesPane.setVisible(true);
|
||||||
this.tablesPane.showTables();
|
this.tablesPane.showTables();
|
||||||
setActive(tablesPane);
|
setActive(tablesPane);
|
||||||
|
if (!setActive && topPane != null) {
|
||||||
|
setActive(topPane);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideGames() {
|
public void hideGames() {
|
||||||
|
|
|
@ -337,7 +337,7 @@ public class ConnectDialog extends MageDialog {
|
||||||
if (result) {
|
if (result) {
|
||||||
lblStatus.setText("");
|
lblStatus.setText("");
|
||||||
connected();
|
connected();
|
||||||
MageFrame.getInstance().showGames();
|
MageFrame.getInstance().showGames(false);
|
||||||
} else {
|
} else {
|
||||||
lblStatus.setText("Could not connect");
|
lblStatus.setText("Could not connect");
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,8 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public class ChatManager {
|
public class ChatManager {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(ChatManager.class);
|
||||||
|
|
||||||
private static final ChatManager INSTANCE = new ChatManager();
|
private static final ChatManager INSTANCE = new ChatManager();
|
||||||
|
|
||||||
public static ChatManager getInstance() {
|
public static ChatManager getInstance() {
|
||||||
|
@ -59,18 +61,27 @@ public class ChatManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void joinChat(UUID chatId, UUID userId) {
|
public void joinChat(UUID chatId, UUID userId) {
|
||||||
chatSessions.get(chatId).join(userId);
|
if (chatSessions.containsKey(chatId)) {
|
||||||
|
chatSessions.get(chatId).join(userId);
|
||||||
|
} else {
|
||||||
|
logger.debug("ChatManager:joinChat - chatId does not exist - chatId: " + chatId +" userId: " + userId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leaveChat(UUID chatId, UUID userId) {
|
public void leaveChat(UUID chatId, UUID userId) {
|
||||||
if (chatSessions.containsKey(chatId)) {
|
if (chatSessions.containsKey(chatId)) {
|
||||||
chatSessions.get(chatId).kill(userId, DisconnectReason.CleaningUp);
|
chatSessions.get(chatId).kill(userId, DisconnectReason.CleaningUp);
|
||||||
|
} else {
|
||||||
|
logger.debug("ChatManager:leaveChat - chatId does not exist - chatId: " + chatId +" userId: " + userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroyChatSession(UUID chatId) {
|
public void destroyChatSession(UUID chatId) {
|
||||||
if (chatId != null) {
|
if (chatId != null && chatSessions.containsKey(chatId)) {
|
||||||
chatSessions.remove(chatId);
|
chatSessions.remove(chatId);
|
||||||
|
} else {
|
||||||
|
logger.debug("ChatManager:destroy chat - chatId does not exist - chatId: " + chatId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1004,6 +1004,9 @@ public class MageServerImpl implements MageServer {
|
||||||
protected void execute(final String actionName, final String sessionId, final Action action) throws MageException {
|
protected void execute(final String actionName, final String sessionId, final Action action) throws MageException {
|
||||||
if (SessionManager.getInstance().isValidSession(sessionId)) {
|
if (SessionManager.getInstance().isValidSession(sessionId)) {
|
||||||
try {
|
try {
|
||||||
|
if (actionName.equals("joinChat")) {
|
||||||
|
logger.debug("MageServerImpl.execute sessionId: " + sessionId + " action: " + actionName);
|
||||||
|
}
|
||||||
callExecutor.execute(
|
callExecutor.execute(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -192,8 +191,17 @@ public class Session {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void userLostConnection() {
|
//synchronized public void userLostConnection() {
|
||||||
|
public void userLostConnection() {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
|
if (user == null) {
|
||||||
|
logger.error("Session.userLostConnection user for session not found sessionId: " + sessionId + " userId: " +userId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (user.getSessionId().isEmpty()) {
|
||||||
|
logger.debug("Session.userLostConnection user was already disconnected sessionId: " + sessionId + " userId: " +userId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (logger.isInfoEnabled()) {
|
if (logger.isInfoEnabled()) {
|
||||||
StringBuilder sb = new StringBuilder("user ");
|
StringBuilder sb = new StringBuilder("user ");
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
@ -218,7 +226,7 @@ public class Session {
|
||||||
call.setMessageId(messageId++);
|
call.setMessageId(messageId++);
|
||||||
callbackHandler.handleCallbackOneway(new Callback(call));
|
callbackHandler.handleCallbackOneway(new Callback(call));
|
||||||
} catch (HandleCallbackException ex) {
|
} catch (HandleCallbackException ex) {
|
||||||
logger.fatal(new StringBuilder("Session of userId ").append(userId).append(" fireCallback error: ").append(ex.getMessage()).toString(), ex);
|
logger.info(new StringBuilder("Session of userId ").append(userId).append(" callback exception: ").append(ex.getMessage()).toString());
|
||||||
userLostConnection();
|
userLostConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue