We are developing a multiplayer online game with smartfox server version 2.0.
Java api as server side and flash as client side.
the problem we are facing is :
when the client is trying to login with invalid credentials we are validating with a method
"getApi().checkSecurePassword(session, dbPassword, cryptedPass)" in java.
if the credentials are valid we are making him login and joining the user.
But if credentials are not valid we are throwing a login exception.
The problem is after throwing a exception server is removing session from server that is after 10 to 15
secs.
If the user enters valid credentials and logs in , still the client recieves the session removed event.
Please suggest how to handle this situation.
the code we used for this is :
Code: Select all
" IDBManager dbManager = getParentExtension().getParentZone()
.getDBManager();
Connection connection;
try {
// Grab a connection from the DBManager connection pool
connection = dbManager.getConnection();
// Build a prepared statement
PreparedStatement stmt = connection
.prepareStatement("SELECT password,user_id FROM user WHERE user_id=?");
stmt.setString(1, userName.trim());
// Execute query
ResultSet res = stmt.executeQuery();
// Verify that one record was found
if (!res.first()) {
// This is the part that goes to the client
SFSErrorData errData = new SFSErrorData(
SFSErrorCode.LOGIN_BAD_USERNAME);
errData.addParameter(userName);
// This is logged on the server side
throw new SFSLoginException("Baddd user name: " + userName,
errData);
}
String dbPword = res.getString("password");
// Verify the secure password
if (!getApi()
.checkSecurePassword(session, dbPword, cryptedPass)) {
SFSErrorData data = new SFSErrorData(
SFSErrorCode.LOGIN_BAD_PASSWORD);
data.addParameter(userName);
throw new SFSLoginException("Login failed for user: "
+ userName, data);
}
// Return connection to the DBManager connection pool
connection.close();
"
thanks.