Added missing flip in ErrorMessage packet, Added null session checks before attempting to login players

This commit should also fix the never-ending "Connecting to Galaxy..."
loop. It should also be noted that for some reason any ErrorMessage
packet sent before a player is logged in always says that the "Login
Server is unavailable at this time".
This commit is contained in:
Waverunner
2014-07-14 10:24:29 -04:00
parent 2f8c086a1b
commit 85369cd938
2 changed files with 25 additions and 7 deletions
+24 -6
View File
@@ -92,6 +92,11 @@ public class LoginService implements INetworkDispatch{
public void handlePacket(IoSession session, IoBuffer data) throws Exception {
if (session == null) {
System.out.println("Login attempted with NULL session!");
return;
}
data = data.order(ByteOrder.LITTLE_ENDIAN);
LoginClientId clientID = new LoginClientId();
data.position(0);
@@ -116,16 +121,19 @@ public class LoginService implements INetworkDispatch{
err = "user is banned";
break;
}
ErrorMessage errMsg = new ErrorMessage("Invalid Login", err);
// No matter what, this will always show that the login server is unavailable at this time. Removing the error message will just keep the connecting message up.
ErrorMessage errMsg = new ErrorMessage("Wrong Password", "The username or password you entered was incorrect.");
session.write(errMsg.serialize());
Disconnect disconnect = new Disconnect((Integer)session.getAttribute("connectionId"), 6);
session.write(disconnect);
session.close(false);
// Closing the session for some reason will not show any error messages, even if write messages are queued..
//As result, the infinite "Connecting to galaxy..." loop., also it randomly denies any logins from that client for some reason
return;
}
System.out.println(user + " successfully logged in.");
Client client = new Client(session.getRemoteAddress());
client.setAccountName(user);
client.setPassword(pass);
@@ -137,6 +145,16 @@ public class LoginService implements INetworkDispatch{
core.addClient(session, client);
if (!core.getActiveConnectionsMap().containsKey(session)) {
Disconnect disconnect = new Disconnect((Integer)session.getAttribute("connectionId"), 6);
session.write(disconnect);
ErrorMessage errMsg = new ErrorMessage("Error Logging In", "Your client could not be added to the connections at this time.");
session.write(errMsg.serialize());
session.close(false);
System.out.println(client.getAccountName() + " was not added to active connections map.");
return;
}
/*if(!checkIfAccountExistInGameDB(id)) {
createAccountForGameDB(id, user, email, encryptPass);
}*/
@@ -153,9 +171,7 @@ public class LoginService implements INetworkDispatch{
ServerNowEpochTime time = new ServerNowEpochTime((int) (System.currentTimeMillis() / 1000));
if (client.getSession().containsAttribute("tradeSession") == true) {
System.out.println("Has attribute: " + session.getAttribute("tradeSession").toString());
client.getSession().removeAttribute("tradeSession");
System.out.println("Removed tradeSession Attribute @ LoginService.java");
}
session.write(time.serialize());
@@ -165,6 +181,8 @@ public class LoginService implements INetworkDispatch{
session.write(serverStatus.serialize());
session.write(jediSlot.serialize());
session.write(characters.serialize());
System.out.println(user + " successfully logged in.");
}
});