in theory this will work

This commit is contained in:
DarthArgus
2016-12-26 14:50:53 -06:00
parent 39d41ee779
commit c99fee4802
6 changed files with 39 additions and 11 deletions
@@ -8,13 +8,8 @@
#include "FirstLoginServer.h"
#include "ClientConnection.h"
#include "Archive/ByteStream.h"
#include "ConfigLoginServer.h"
#include "DatabaseConnection.h"
#include "SessionApiClient.h"
#include "TaskMapAccount.h"
#include "serverKeyShare/KeyShare.h"
#include "sharedFoundation/ApplicationVersion.h"
#include "sharedLog/Log.h"
#include "sharedNetworkMessages/ClientLoginMessages.h"
#include "sharedNetworkMessages/DeleteCharacterMessage.h"
@@ -25,8 +20,6 @@
#include "sharedFoundation/CrcConstexpr.hpp"
//#include <algorithm>
#include "webAPI.h"
using namespace StellaBellum;
@@ -244,11 +237,27 @@ void ClientConnection::validateClient(const std::string & id, const std::string
uname.resize(MAX_ACCOUNT_NAME_LENGTH);
}
suid = std::hash<std::string>(uname.c_str());
std::hash<std::string> h;
suid = h(uname.c_str());
}
// insert all related accounts, if not already there, into the db
//taskmapaccount
std::string parentAccount = api.getString("mainAccount");
vector<std::string> childAccounts = api.getVector<std::string>("subAccounts");
if (childAccounts.size() == 0) {
for (auto i = childAccounts.begin(); i != childAccounts.end(); ++i) {
if (!i.empty()) {
std::hash<std::string> tmphash;
if (i.length() > MAX_ACCOUNT_NAME_LENGTH) {
i.resize(MAX_ACCOUNT_NAME_LENGTH);
}
// insert all related accounts, if not already there, into the db
DatabaseConnection::getInstance().upsertAccountRelationship(suid, tmphash(i));
}
}
}
LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s)", m_stationId, getRemoteAddress().c_str(), uname.c_str()));
@@ -20,6 +20,7 @@
#include "TaskGetCharactersForDelete.h"
#include "TaskGetClusterList.h"
#include "TaskGetValidationData.h"
#include "TaskMapAccount.h"
#include "TaskRegisterNewCluster.h"
#include "TaskRenameCharacter.h"
#include "TaskRestoreCharacter.h"
@@ -163,6 +164,12 @@ void DatabaseConnection::getAccountValidationData(const TransferRequestMoveValid
// ----------------------------------------------------------------------
void DatabaseConnection::upsertAccountRelationship(StationId parentID, StationId childID) {
m_taskQueue->asyncRequest(new TaskMapAccount(parentID, childID));
}
// ----------------------------------------------------------------------
void DatabaseConnection::deleteCharacter(uint32 clusterId, const NetworkId &characterId, StationId stationId)
{
NOT_NULL(m_taskQueue);
@@ -47,6 +47,7 @@ class DatabaseConnection : public Singleton<DatabaseConnection>
void update ();
void getAccountValidationData (StationId stationId, uint32 clusterId, unsigned int track, uint32 subscriptionBits);
void getAccountValidationData (const TransferRequestMoveValidation & request, uint32 clusterId);
void upsertAccountRelationship (StationId parentID, StationId childID);
void deleteCharacter (uint32 clusterId, const NetworkId &characterId, StationId stationId);
void deleteAllCharacters (StationId stationId);
void renameCharacter (uint32 clusterId, const NetworkId &characterId, const Unicode::String &newName, const TransferCharacterData * requestData);
@@ -1,7 +1,7 @@
// ======================================================================
//
// TaskMapAccount.cpp
// copyright (c) 2001 Sony Online Entertainment
// copyright (c) 2016 StellaBellum
//
// ======================================================================
+8
View File
@@ -55,6 +55,14 @@ std::string webAPI::getString(const std::string &slot) {
return std::string("");
}
std::vector<std::string> getStringVector(const std::string &slot) {
if (!this->responseData.empty() && !slot.empty() && responseData.count(slot) && !this->responseData[slot].is_null()) {
return this->responseData[slot].get<std::vector<std::string>>();
}
return std::vector<std::string>();
}
bool webAPI::submit(const int &reqType, const int &getPost, const int &respType) {
if (reqType == DTYPE::JSON) // json request
{
+3
View File
@@ -59,6 +59,9 @@ namespace StellaBellum {
// get a string from a given slot
std::string getString(const std::string &slot);
// get a vector of strings from a given slot
std::vector<std::string> getStringVector(const std::string &slot);
// set json key and value for request
template<typename T> bool addJsonData(const std::string &key, const T &value) {
if (!key.empty() &&