Browse Source

Methods moved out of old login handler

combat-2
MagicBot 8 months ago
parent
commit
4e5e49606c
  1. 25
      src/engine/net/client/handlers/ClientLoginInfoMsgHandler.java
  2. 10
      src/engine/net/client/handlers/CommitNewCharacterMsgHandler.java
  3. 13
      src/engine/net/client/handlers/DeleteCharacterMsgHandler.java
  4. 8
      src/engine/net/client/handlers/GameServerIPRequestMsgHandler.java
  5. 4
      src/engine/net/client/handlers/ServerInfoMsgHandler.java
  6. 7
      src/engine/net/client/handlers/VersionInfoMsgHandler.java
  7. 11
      src/engine/objects/PlayerCharacter.java
  8. 53
      src/engine/server/login/LoginServer.java
  9. 57
      src/engine/server/login/LoginServerMsgHandler.java

25
src/engine/net/client/handlers/ClientLoginInfoMsgHandler.java

@ -20,7 +20,6 @@ import engine.objects.Account; @@ -20,7 +20,6 @@ import engine.objects.Account;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import engine.server.login.LoginServer;
import engine.server.login.LoginServerMsgHandler;
import engine.session.Session;
import org.pmw.tinylog.Logger;
@ -49,17 +48,17 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler { @@ -49,17 +48,17 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler {
// Check to see if there is actually any data in uname.pass
if (uname.length() == 0) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "The username provided was zero length.", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "The username provided was zero length.", origin);
return true;
}
if (pass.length() == 0) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "The password provided was zero length.", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "The password provided was zero length.", origin);
return true;
}
if (LoginServer.loginServerRunning == false) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_LOGINSERVER_BUSY, "", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_LOGINSERVER_BUSY, "", origin);
return true;
}
@ -73,7 +72,7 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler { @@ -73,7 +72,7 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler {
if (account == null) {
if (ConfigManager.MB_LOGIN_AUTOREG.getValue().equalsIgnoreCase("false")) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', origin);
Logger.info("Could not find account (" + uname + ')');
return true;
}
@ -83,7 +82,7 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler { @@ -83,7 +82,7 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler {
account = DbManager.AccountQueries.GET_ACCOUNT(uname);
if (account == null) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', origin);
Logger.info("Could not auto-create (" + uname + ')');
return true;
}
@ -96,7 +95,7 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler { @@ -96,7 +95,7 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler {
// Check number invalid login attempts. If 5 or greater, kick to login.
if (account.getLoginAttempts() >= MBServerStatics.MAX_LOGIN_ATTEMPTS) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Too many login in attempts for '" + uname + '\'', origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Too many login in attempts for '" + uname + '\'', origin);
Logger.info("Too many login in attempts for '" + uname + '\'');
return true;
}
@ -110,19 +109,19 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler { @@ -110,19 +109,19 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler {
if (!account.passIsValid(pass, origin.getClientIpAddress(), origin.machineID)) {
account.incrementLoginAttempts();
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "", origin);
Logger.info("Incorrect password(" + uname + ')');
return true;
}
} catch (IllegalArgumentException e1) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "", origin);
Logger.info("Failed forum account validation(" + uname + ')');
}
// Account deactivated
if (account.status.equals(Enum.AccountStatus.BANNED)) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_NO_MORE_PLAYTIME_ON_ACCOUNT, "", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_NO_MORE_PLAYTIME_ON_ACCOUNT, "", origin);
return true;
}
@ -132,7 +131,7 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler { @@ -132,7 +131,7 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler {
// If there is, then the account is in use and must be handled:
// kick the 'other connection'
if (session != null)
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Your account has been accessed from a different IP & Port.", session.getConn()); // Logout the character
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Your account has been accessed from a different IP & Port.", session.getConn()); // Logout the character
// TODO implement character logout
@ -153,10 +152,10 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler { @@ -153,10 +152,10 @@ public class ClientLoginInfoMsgHandler extends AbstractClientMsgHandler {
// send character select screen
try {
LoginServerMsgHandler.sendCharacterSelectScreen(session);
LoginServer.sendCharacterSelectScreen(session);
} catch (Exception e) {
Logger.error("Unable to Send Character Select Screen to client");
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send Character Select Screen to client.", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send Character Select Screen to client.", origin);
return true;
}

10
src/engine/net/client/handlers/CommitNewCharacterMsgHandler.java

@ -15,7 +15,7 @@ import engine.net.client.msg.ClientNetMsg; @@ -15,7 +15,7 @@ import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.login.CommitNewCharacterMsg;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import engine.server.login.LoginServerMsgHandler;
import engine.server.login.LoginServer;
import org.pmw.tinylog.Logger;
public class CommitNewCharacterMsgHandler extends AbstractClientMsgHandler {
@ -35,7 +35,7 @@ public class CommitNewCharacterMsgHandler extends AbstractClientMsgHandler { @@ -35,7 +35,7 @@ public class CommitNewCharacterMsgHandler extends AbstractClientMsgHandler {
try {
// Check to see if there is an available slot.
if (origin.getAccount().characterMap.size() >= MBServerStatics.MAX_NUM_OF_CHARACTERS) {
LoginServerMsgHandler.sendCharacterSelectScreen(SessionManager.getSession(origin));
LoginServer.sendCharacterSelectScreen(SessionManager.getSession(origin));
return true;
}
@ -43,7 +43,7 @@ public class CommitNewCharacterMsgHandler extends AbstractClientMsgHandler { @@ -43,7 +43,7 @@ public class CommitNewCharacterMsgHandler extends AbstractClientMsgHandler {
if (newPlayer == null) {
Logger.info("Player returned null while creating character.");
LoginServerMsgHandler.sendCharacterSelectScreen(SessionManager.getSession(origin), true);
LoginServer.sendCharacterSelectScreen(SessionManager.getSession(origin), true);
return true;
}
@ -51,11 +51,11 @@ public class CommitNewCharacterMsgHandler extends AbstractClientMsgHandler { @@ -51,11 +51,11 @@ public class CommitNewCharacterMsgHandler extends AbstractClientMsgHandler {
origin.getAccount().characterMap.putIfAbsent(newPlayer.getObjectUUID(), newPlayer);
// Send back to Character Select Screen
LoginServerMsgHandler.sendCharacterSelectScreen(SessionManager.getSession(origin), true);
LoginServer.sendCharacterSelectScreen(SessionManager.getSession(origin), true);
} catch (Exception e) {
Logger.error(e);
LoginServerMsgHandler.sendCharacterSelectScreen(SessionManager.getSession(origin), true);
LoginServer.sendCharacterSelectScreen(SessionManager.getSession(origin), true);
}
return true;

13
src/engine/net/client/handlers/DeleteCharacterMsgHandler.java

@ -17,7 +17,6 @@ import engine.objects.GuildStatusController; @@ -17,7 +17,6 @@ import engine.objects.GuildStatusController;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import engine.server.login.LoginServer;
import engine.server.login.LoginServerMsgHandler;
import engine.session.Session;
import org.pmw.tinylog.Logger;
@ -47,19 +46,19 @@ public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler { @@ -47,19 +46,19 @@ public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler {
if (playerCharacter == null) {
Logger.error("Delete Error: PlayerID=" + msg.getCharacterUUID() + " not found.");
LoginServerMsgHandler.sendCharacterSelectScreen(session);
LoginServer.sendCharacterSelectScreen(session);
return true;
}
if (session.getAccount() == null) {
Logger.error("Delete Error: Account not found.");
LoginServerMsgHandler.sendCharacterSelectScreen(session);
LoginServer.sendCharacterSelectScreen(session);
return true;
}
if (playerCharacter.getAccount().equals(session.getAccount()) == false) {
Logger.error("Delete Error: Character " + playerCharacter.getName() + " does not belong to account " + origin.getAccount().getUname());
LoginServerMsgHandler.sendCharacterSelectScreen(session);
LoginServer.sendCharacterSelectScreen(session);
return true;
}
@ -67,7 +66,7 @@ public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler { @@ -67,7 +66,7 @@ public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler {
//TODO either find an error or just gdisband.
if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus())) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Cannot delete a guild leader.", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Cannot delete a guild leader.", origin);
return true;
}
@ -75,7 +74,7 @@ public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler { @@ -75,7 +74,7 @@ public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler {
if (LoginServer.getActiveBaneQuery(playerCharacter)) {
Logger.info("Character " + playerCharacter.getName() + " has unresolved bane");
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Player has unresolved bane.", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Player has unresolved bane.", origin);
return true;
}
@ -84,7 +83,7 @@ public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler { @@ -84,7 +83,7 @@ public class DeleteCharacterMsgHandler extends AbstractClientMsgHandler {
// TODO Delete Equipment
// Resend Character Select Screen.
LoginServerMsgHandler.sendCharacterSelectScreen(session);
LoginServer.sendCharacterSelectScreen(session);
} catch (Exception e) {
Logger.error(e);

8
src/engine/net/client/handlers/GameServerIPRequestMsgHandler.java

@ -17,7 +17,7 @@ import engine.net.client.msg.login.GameServerIPResponseMsg; @@ -17,7 +17,7 @@ import engine.net.client.msg.login.GameServerIPResponseMsg;
import engine.objects.Account;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import engine.server.login.LoginServerMsgHandler;
import engine.server.login.LoginServer;
import engine.session.CSSession;
import engine.session.Session;
import engine.util.ByteUtils;
@ -45,14 +45,14 @@ public class GameServerIPRequestMsgHandler extends AbstractClientMsgHandler { @@ -45,14 +45,14 @@ public class GameServerIPRequestMsgHandler extends AbstractClientMsgHandler {
if (playerCharacter == null) {
Logger.info("Unable to find character ID " + msg.getCharacterUUID());
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "PlayerCharacter lookup failed in .RequestGameServer().", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "PlayerCharacter lookup failed in .RequestGameServer().", origin);
return true;
}
try {
if (!CSSession.updateCrossServerSession(ByteUtils.byteArrayToSafeStringHex(origin.getSecretKeyBytes()), msg.getCharacterUUID())) {
Logger.info("Failed to update Cross server session, Kicking to Login for Character " + playerCharacter.getObjectUUID());
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Failed to update Session Information", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Failed to update Session Information", origin);
return true;
}
} catch (Exception e) {
@ -68,7 +68,7 @@ public class GameServerIPRequestMsgHandler extends AbstractClientMsgHandler { @@ -68,7 +68,7 @@ public class GameServerIPRequestMsgHandler extends AbstractClientMsgHandler {
if (!origin.sendMsg(gameServerIPResponseMsg)) {
Logger.error("Failed to send message");
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send GameServerIPResponseMsg to client.", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send GameServerIPResponseMsg to client.", origin);
}

4
src/engine/net/client/handlers/ServerInfoMsgHandler.java

@ -14,7 +14,7 @@ import engine.net.client.msg.ClientNetMsg; @@ -14,7 +14,7 @@ import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ServerInfoMsg;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import engine.server.login.LoginServerMsgHandler;
import engine.server.login.LoginServer;
import org.pmw.tinylog.Logger;
public class ServerInfoMsgHandler extends AbstractClientMsgHandler {
@ -40,7 +40,7 @@ public class ServerInfoMsgHandler extends AbstractClientMsgHandler { @@ -40,7 +40,7 @@ public class ServerInfoMsgHandler extends AbstractClientMsgHandler {
if (!origin.sendMsg(sim)) {
Logger.error("Failed to send message");
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send ServerInfoMsg to client.", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send ServerInfoMsg to client.", origin);
}
return true;

7
src/engine/net/client/handlers/VersionInfoMsgHandler.java

@ -15,7 +15,6 @@ import engine.net.client.msg.login.VersionInfoMsg; @@ -15,7 +15,6 @@ import engine.net.client.msg.login.VersionInfoMsg;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import engine.server.login.LoginServer;
import engine.server.login.LoginServerMsgHandler;
public class VersionInfoMsgHandler extends AbstractClientMsgHandler {
@ -43,7 +42,7 @@ public class VersionInfoMsgHandler extends AbstractClientMsgHandler { @@ -43,7 +42,7 @@ public class VersionInfoMsgHandler extends AbstractClientMsgHandler {
cMinorVer = msg.getMinorVersion();
if (!cMajorVer.equals(LoginServer.getDefaultVersionInfo().getMajorVersion())) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Major Version Failure: " + cMajorVer, origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Major Version Failure: " + cMajorVer, origin);
return true;
}
@ -53,12 +52,12 @@ public class VersionInfoMsgHandler extends AbstractClientMsgHandler { @@ -53,12 +52,12 @@ public class VersionInfoMsgHandler extends AbstractClientMsgHandler {
} */
if (cMinorVer == null) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: ", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: ", origin);
return true;
}
if (cMinorVer.length() < 8 || cMinorVer.length() > 16) {
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: ", origin);
LoginServer.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: ", origin);
return true;
}

11
src/engine/objects/PlayerCharacter.java

@ -38,7 +38,6 @@ import engine.net.client.msg.login.CommitNewCharacterMsg; @@ -38,7 +38,6 @@ import engine.net.client.msg.login.CommitNewCharacterMsg;
import engine.powers.EffectsBase;
import engine.server.MBServerStatics;
import engine.server.login.LoginServer;
import engine.server.login.LoginServerMsgHandler;
import engine.server.world.WorldServer;
import engine.util.MiscUtils;
import org.joda.time.DateTime;
@ -740,28 +739,28 @@ public class PlayerCharacter extends AbstractCharacter { @@ -740,28 +739,28 @@ public class PlayerCharacter extends AbstractCharacter {
String lastName = msg.getLastName().trim();
if (firstName.length() < 3) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTNAME_MUST_BE_LONGER,
LoginServer.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTNAME_MUST_BE_LONGER,
clientConnection);
return null;
}
// Ensure names are below required length
if (firstName.length() > 15 || lastName.length() > 15) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTANDLAST_MUST_BE_SHORTER,
LoginServer.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTANDLAST_MUST_BE_SHORTER,
clientConnection);
return null;
}
// Check if firstname is valid
if (MiscUtils.checkIfFirstNameInvalid(firstName)) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_PLEASE_CHOOSE_ANOTHER_FIRSTNAME,
LoginServer.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_PLEASE_CHOOSE_ANOTHER_FIRSTNAME,
clientConnection);
return null;
}
// Check if last name is valid
if (MiscUtils.checkIfLastNameInvalid(lastName)) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_LASTNAME_UNAVAILABLE,
LoginServer.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_LASTNAME_UNAVAILABLE,
clientConnection);
return null;
}
@ -1136,7 +1135,7 @@ public class PlayerCharacter extends AbstractCharacter { @@ -1136,7 +1135,7 @@ public class PlayerCharacter extends AbstractCharacter {
// This must be the very last check before calling the
// DB to create the character record
if (DbManager.PlayerCharacterQueries.IS_CHARACTER_NAME_UNIQUE(firstName) == false) {
LoginServerMsgHandler.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTNAME_UNAVAILABLE,
LoginServer.sendInvalidNameMsg(firstName, lastName, MBServerStatics.INVALIDNAME_FIRSTNAME_UNAVAILABLE,
clientConnection);
return null;
}

53
src/engine/server/login/LoginServer.java

@ -13,15 +13,18 @@ import engine.Enum; @@ -13,15 +13,18 @@ import engine.Enum;
import engine.gameManager.*;
import engine.job.JobScheduler;
import engine.jobs.CSessionCleanupJob;
import engine.jobs.DisconnectJob;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.Network;
import engine.net.client.ClientConnection;
import engine.net.client.ClientConnectionManager;
import engine.net.client.Protocol;
import engine.net.client.msg.login.ServerStatusMsg;
import engine.net.client.msg.login.VersionInfoMsg;
import engine.net.client.msg.login.*;
import engine.objects.*;
import engine.server.MBServerStatics;
import engine.server.world.WorldServer;
import engine.session.Session;
import engine.util.ByteUtils;
import engine.util.ThreadUtils;
import org.pmw.tinylog.Configurator;
@ -170,6 +173,52 @@ public class LoginServer { @@ -170,6 +173,52 @@ public class LoginServer {
return portInUse;
}
public static void sendInvalidNameMsg(String firstName, String lastName, int errorCode, ClientConnection clientConnection) {
InvalidNameMsg invalidNameMessage;
if (firstName.length() > 256 || lastName.length() > 256)
invalidNameMessage = new InvalidNameMsg(firstName, lastName, errorCode);
else
invalidNameMessage = new InvalidNameMsg(firstName, lastName, errorCode);
clientConnection.sendMsg(invalidNameMessage);
}
public static void KickToLogin(int errCode, String message, ClientConnection origin) {
LoginErrorMsg msg = new LoginErrorMsg(errCode, message);
PlayerCharacter player = origin.getPlayerCharacter();
if (player == null) {
origin.sendMsg(msg);
} else {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
}
Logger.info("Kicking to Login. Message: '" + message + '\'');
DisconnectJob dj = new DisconnectJob(origin);
JobScheduler.getInstance().scheduleJob(dj, 250);
}
public static void sendCharacterSelectScreen(Session s) {
sendCharacterSelectScreen(s, false);
}
public static void sendCharacterSelectScreen(Session s, boolean fromCommit) {
if (s.getAccount() != null) {
CharSelectScreenMsg cssm = new CharSelectScreenMsg(s, fromCommit);
s.getConn().sendMsg(cssm);
} else {
Logger.error("No Account Found: Unable to Send Character Select Screen");
KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send Character Select Screen to client.", s.getConn());
}
}
private void exec() {

57
src/engine/server/login/LoginServerMsgHandler.java

@ -9,21 +9,10 @@ @@ -9,21 +9,10 @@
package engine.server.login;
import engine.Enum.DispatchChannel;
import engine.job.JobScheduler;
import engine.jobs.DisconnectJob;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.NetMsgHandler;
import engine.net.client.ClientConnection;
import engine.net.client.Protocol;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.login.CharSelectScreenMsg;
import engine.net.client.msg.login.InvalidNameMsg;
import engine.net.client.msg.login.LoginErrorMsg;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import engine.session.Session;
import org.pmw.tinylog.Logger;
public class LoginServerMsgHandler implements NetMsgHandler {
@ -35,18 +24,6 @@ public class LoginServerMsgHandler implements NetMsgHandler { @@ -35,18 +24,6 @@ public class LoginServerMsgHandler implements NetMsgHandler {
this.server = server;
}
public static void sendInvalidNameMsg(String firstName, String lastName, int errorCode, ClientConnection clientConnection) {
InvalidNameMsg invalidNameMessage;
if (firstName.length() > 256 || lastName.length() > 256)
invalidNameMessage = new InvalidNameMsg(firstName, lastName, errorCode);
else
invalidNameMessage = new InvalidNameMsg(firstName, lastName, errorCode);
clientConnection.sendMsg(invalidNameMessage);
}
/*
* =========================================================================
* Client Messages
@ -67,38 +44,4 @@ public class LoginServerMsgHandler implements NetMsgHandler { @@ -67,38 +44,4 @@ public class LoginServerMsgHandler implements NetMsgHandler {
}
public static void KickToLogin(int errCode, String message, ClientConnection origin) {
LoginErrorMsg msg = new LoginErrorMsg(errCode, message);
PlayerCharacter player = origin.getPlayerCharacter();
if (player == null) {
origin.sendMsg(msg);
} else {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
}
Logger.info("Kicking to Login. Message: '" + message + '\'');
DisconnectJob dj = new DisconnectJob(origin);
JobScheduler.getInstance().scheduleJob(dj, 250);
}
public static void sendCharacterSelectScreen(Session s) {
sendCharacterSelectScreen(s, false);
}
public static void sendCharacterSelectScreen(Session s, boolean fromCommit) {
if (s.getAccount() != null) {
CharSelectScreenMsg cssm = new CharSelectScreenMsg(s, fromCommit);
s.getConn().sendMsg(cssm);
} else {
Logger.error("No Account Found: Unable to Send Character Select Screen");
LoginServerMsgHandler.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send Character Select Screen to client.", s.getConn());
}
}
}

Loading…
Cancel
Save