refactor: improved and reorganized client-server api, added additional logs, fixed miss admin checks for some commands

This commit is contained in:
Oleg Agafonov 2023-11-22 23:52:00 +04:00
parent e43e918c67
commit 75958e3710
21 changed files with 371 additions and 364 deletions

View file

@ -26,13 +26,12 @@ import java.util.*;
/**
* Network: client side session
*
* Only one session/server per GUI's client
* Only one session/server per GUI's client supports
*
* Created by IGOUDT on 15-9-2016.
* @author IGOUDT
*/
public final class SessionHandler {
private static final Logger logger = Logger.getLogger(SessionHandler.class);
private static Session session;
@ -65,7 +64,7 @@ public final class SessionHandler {
public static boolean connect(Connection connection) {
lastConnectError = "";
if (session.connect(connection)) {
if (session.connectStart(connection)) {
return true;
} else {
lastConnectError = session.getLastError();
@ -78,11 +77,11 @@ public final class SessionHandler {
}
public static boolean stopConnecting() {
return session.stopConnecting();
return session.connectAbort();
}
public static void disconnect(boolean showmessage) {
session.disconnect(showmessage);
session.connectStop(showmessage);
}
public static void sendPlayerAction(PlayerAction playerAction, UUID gameId, Object relatedUserId) {
@ -377,14 +376,14 @@ public final class SessionHandler {
}
public static boolean emailAuthToken(Connection connection) {
return session.emailAuthToken(connection);
return session.sendAuthSendTokenToEmail(connection);
}
public static boolean resetPassword(Connection connection) {
return session.resetPassword(connection);
return session.sendAuthResetPassword(connection);
}
public static boolean register(Connection connection) {
return session.register(connection);
return session.sendAuthRegister(connection);
}
}

View file

@ -507,7 +507,7 @@ public class NewTableDialog extends MageDialog {
for (TablePlayerPanel player : players) {
if (player.getPlayerType() != PlayerType.HUMAN) {
if (!player.joinTable(roomId, table.getTableId())) {
// error message must be send by the server
// error message must be sent by a server
SessionHandler.removeTable(roomId, table.getTableId());
table = null;
return;