Handler created for GameServerIPRequestMsg
This commit is contained in:
@@ -10,9 +10,6 @@
|
||||
package engine.server.login;
|
||||
|
||||
import engine.Enum.DispatchChannel;
|
||||
import engine.Enum.GameObjectType;
|
||||
import engine.gameManager.DbManager;
|
||||
import engine.gameManager.SessionManager;
|
||||
import engine.job.JobScheduler;
|
||||
import engine.jobs.DisconnectJob;
|
||||
import engine.net.Dispatch;
|
||||
@@ -21,14 +18,12 @@ 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.*;
|
||||
import engine.objects.Account;
|
||||
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.CSSession;
|
||||
import engine.session.Session;
|
||||
import engine.util.ByteUtils;
|
||||
import engine.util.StringUtils;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
public class LoginServerMsgHandler implements NetMsgHandler {
|
||||
@@ -68,29 +63,6 @@ public class LoginServerMsgHandler implements NetMsgHandler {
|
||||
ClientConnection origin = (ClientConnection) clientNetMsg.getOrigin();
|
||||
Protocol protocolMsg = clientNetMsg.getProtocolMsg();
|
||||
|
||||
try {
|
||||
|
||||
switch (protocolMsg) {
|
||||
|
||||
case SELECTCHAR:
|
||||
this.RequestGameServer((GameServerIPRequestMsg) clientNetMsg, origin);
|
||||
break;
|
||||
|
||||
case TARGETOBJECT:
|
||||
// Why is this being sent to login server?
|
||||
break;
|
||||
|
||||
default:
|
||||
String ocHex = StringUtils.toHexString(protocolMsg.opcode);
|
||||
Logger.error("Cannot not handle Opcode: " + ocHex);
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error("protocolMsg:" + protocolMsg + e.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -129,40 +101,4 @@ public class LoginServerMsgHandler implements NetMsgHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void RequestGameServer(GameServerIPRequestMsg gameServerIPRequestMessage, ClientConnection conn) {
|
||||
|
||||
Session session;
|
||||
PlayerCharacter player;
|
||||
|
||||
session = SessionManager.getSession(conn);
|
||||
player = (PlayerCharacter) DbManager.getObject(GameObjectType.PlayerCharacter, gameServerIPRequestMessage.getCharacterUUID());
|
||||
|
||||
if (player == null) {
|
||||
Logger.info("Unable to find character ID " + gameServerIPRequestMessage.getCharacterUUID());
|
||||
KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "PlayerCharacter lookup failed in .RequestGameServer().", conn);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!CSSession.updateCrossServerSession(ByteUtils.byteArrayToSafeStringHex(conn.getSecretKeyBytes()), gameServerIPRequestMessage.getCharacterUUID())) {
|
||||
Logger.info("Failed to update Cross server session, Kicking to Login for Character " + player.getObjectUUID());
|
||||
this.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Failed to update Session Information", conn);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info("Failed to update Cross server session, Kicking to Login for Character " + player.getObjectUUID());
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
// Set the last character used.
|
||||
Account account = session.getAccount();
|
||||
account.setLastCharIDUsed(gameServerIPRequestMessage.getCharacterUUID());
|
||||
|
||||
GameServerIPResponseMsg gameServerIPResponseMsg = new GameServerIPResponseMsg();
|
||||
|
||||
if (!conn.sendMsg(gameServerIPResponseMsg)) {
|
||||
Logger.error("Failed to send message");
|
||||
this.KickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send GameServerIPResponseMsg to client.", conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user