//====================================================================================================================== void LoginManager::handleDatabaseJobComplete(void* ref, database::DatabaseResult* result) { // Stupid simple hack since we don't have a client for this query if (ref == (void*)1) { _updateServerStatus(result); return; } // This assumes only authentication calls are async right now. Will change as needed. LoginClient* client = (LoginClient*)ref; switch (client->getState()) { case LCSTATE_QueryServerList: { // Auth was successful, now send the server list. _sendServerList(client, result); // Execute our query client->setState(LCSTATE_QueryCharacterList); mDatabase->executeProcedureAsync(this, ref, "CALL %s.sp_ReturnAccountCharacters(%u);",mDatabase->galaxy(), client->getAccountId()); break; } case LCSTATE_QueryCharacterList: { // Query done for the character list, send it out. _sendCharacterList(client, result); break; } case LCSTATE_DeleteCharacter: { // TODO: check returncodes, when using sf database::DataBinding* binding = mDatabase->createDataBinding(1); binding->addField(database::DFT_uint32,0,4); uint32 queryResult; result->getNextRow(binding,&queryResult); uint32 deleteFailed = 1; if (queryResult == 1) { deleteFailed = 0; } mDatabase->destroyDataBinding(binding); _sendDeleteCharacterReply(deleteFailed,client); // _sendDeleteCharacterReply(0,client); } case LCSTATE_RetrieveAccountId: { //check to see if we have an account id _getLauncherSessionKey(client, result); break; } break; default: break; } }
void LoginManager::handleSessionDisconnect(NetworkClient* client) { LoginClient* loginClient = reinterpret_cast<LoginClient*>(client); //gLogger->logMsgF("handleSessionDisconnect account %u",MSG_HIGH,loginClient->getAccountId()); // Client has disconnected. Update the db to show they are no longer authenticated. mDatabase->ExecuteSqlAsync(0, 0, "UPDATE account SET authenticated=0 WHERE account_id=%u;", loginClient->getAccountId()); LoginClientList::iterator iter = mLoginClientList.begin(); while(iter != mLoginClientList.end()) { if(loginClient == (*iter)) { mLoginClientPool.free(*iter); mLoginClientList.erase(iter); break; } ++iter; } }
//====================================================================================================================== void LoginManager::handleSessionDisconnect(NetworkClient* client) { LoginClient* loginClient = reinterpret_cast<LoginClient*>(client); // Client has disconnected. Update the db to show they are no longer authenticated. mDatabase->executeProcedureAsync(0, 0, "UPDATE %s.account SET account_authenticated = 0 WHERE account_id=%u;",mDatabase->galaxy(), loginClient->getAccountId()); LoginClientList::iterator iter = mLoginClientList.begin(); while(iter != mLoginClientList.end()) { if(loginClient == (*iter)) { mLoginClientPool.free(*iter); mLoginClientList.erase(iter); break; } ++iter; } }
void LoginManager::handleDatabaseJobComplete(void* ref, DatabaseResult* result) { // Stupid simple hack since we don't have a client for this query if (ref == (void*)1) { _updateServerStatus(result); return; } // This assumes only authentication calls are async right now. Will change as needed. LoginClient* client = (LoginClient*)ref; switch (client->getState()) { case LCSTATE_QueryAuth: { // Check authentication _authenticateClient(client, result); break; } case LCSTATE_QueryServerList: { // Auth was successful, now send the server list. _sendServerList(client, result); // Execute our query client->setState(LCSTATE_QueryCharacterList); mDatabase->ExecuteSqlAsync(this, ref, "SELECT characters.id, characters.firstname, characters.lastname, characters.galaxy_id, character_appearance.base_model_string FROM characters JOIN (character_appearance) ON (characters.id = character_appearance.character_id) WHERE characters.account_id=%u AND characters.archived=0;", client->getAccountId()); break; } case LCSTATE_QueryCharacterList: { // Query done for the character list, send it out. _sendCharacterList(client, result); break; } case LCSTATE_DeleteCharacter: { // TODO: check returncodes, when using sf DataBinding* binding = mDatabase->CreateDataBinding(1); binding->addField(DFT_uint32,0,4); uint32 queryResult; result->GetNextRow(binding,&queryResult); uint32 deleteFailed = 1; if (queryResult == 1) { deleteFailed = 0; } mDatabase->DestroyDataBinding(binding); _sendDeleteCharacterReply(deleteFailed,client); // _sendDeleteCharacterReply(0,client); } break; default:break; } }