let's see how many typos i have

This commit is contained in:
DarthArgus
2016-09-30 19:57:14 -05:00
parent a67734af5f
commit 109d4234c9
15 changed files with 2505 additions and 2294 deletions
@@ -10,6 +10,8 @@
#include "sharedNetwork/NetworkSetupData.h"
#include "sharedNetworkMessages/ConsoleChannelMessages.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//-----------------------------------------------------------------------
ServerConsoleConnection::ServerConsoleConnection(const std::string & address, const unsigned short port) :
@@ -44,15 +46,21 @@ void ServerConsoleConnection::onReceive(const Archive::ByteStream & bs)
Archive::ReadIterator ri = bs.begin();
GameNetworkMessage m(ri);
ri = bs.begin();
const uint32 messageType = m.getType();
if(m.isType("ConGenericMessage"))
{
ConGenericMessage msg(ri);
fprintf(stdout, "%s", msg.getMsg().c_str());
}
else if(m.isType("RequestDisconnect"))
{
disconnect();
switch(messageType) {
case constcrc("ConGenericMessage") :
{
ConGenericMessage msg(ri);
fprintf(stdout, "%s", msg.getMsg().c_str());
break;
}
case constcrc("RequestDisconnect") :
{
disconnect();
break;
}
}
}
@@ -17,6 +17,8 @@
#include "sharedNetwork/NetworkSetupData.h"
#include "UnicodeUtils.h"
#include "sharedFoundation/CrcConstexpr.hpp"
// ======================================================================
namespace CentralServerConnectionNamespace
@@ -84,19 +86,16 @@ void CentralServerConnection::onReceive(const Archive::ByteStream & message)
GameNetworkMessage msg(ri);
ri = message.begin();
if (msg.isType("SPCharacterProfileMessage"))
if (msg.getType() == constcrc("SPCharacterProfileMessage"))
{
DEBUG_REPORT_LOG(true,(" Got SPCharacterProfileMessage:"));
StationPlayersCollector::handleSPCharacterProfileData(msg);
}
else if ( msg.isType("SomeOtherMessage") )
{
DEBUG_REPORT_LOG(true,(" Got SPCharacterProfileMessage:"));
StationPlayersCollector::handleSPCharacterProfileData(msg);
}
// else if ( msg.isType("SomeOtherMessage") ) {} leaving this here just so i can ask, what the fuck sony?
else
{
DEBUG_REPORT_LOG(true, ("Got (%s) handing off to ServerConnection::onReceive\n", msg.getCmdName().c_str()));
ServerConnection::onReceive(message);
DEBUG_REPORT_LOG(true, ("Got (%s) handing off to ServerConnection::onReceive\n", msg.getCmdName().c_str()));
ServerConnection::onReceive(message);
}
}
@@ -14,6 +14,8 @@
#include "sharedFoundation/Clock.h"
#include "sharedMessageDispatch/Transceiver.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//-----------------------------------------------------------------------
CentralConnection::CentralConnection(TaskConnection * c, const std::string & n) :
@@ -84,30 +86,37 @@ void CentralConnection::receive(const Archive::ByteStream & message)
{
Archive::ReadIterator r(message);
GameNetworkMessage m(r);
r = message.begin();
if(m.isType("TaskSpawnProcess"))
{
TaskSpawnProcess s(r);
IGNORE_RETURN(TaskManager::startServer(s.getProcessName(), s.getOptions(), s.getTargetHostAddress(), s.getSpawnDelay()));
}
else if(m.isType("PreloadFinishedMessage"))
{
PreloadFinishedMessage m(r);
if (m.getFinished())
TaskManager::onPreloadFinished();
}
else if(m.isType("ConGenericMessage"))
{
ConGenericMessage taskConsoleCommand(r);
const uint32 messageType = m.getType();
static std::string command = taskConsoleCommand.getMsg();
while(command.rfind(' ') != command.npos || command.rfind('\n') != command.npos || command.rfind('\r') != command.npos)
switch (messageType) {
case constcrc("TaskSpawnProcess") :
{
command = command.substr(0, command.length() - 1);
TaskSpawnProcess s(r);
IGNORE_RETURN(TaskManager::startServer(s.getProcessName(), s.getOptions(), s.getTargetHostAddress(), s.getSpawnDelay()));
break;
}
case constcrc("PreloadFinishedMessage") :
{
PreloadFinishedMessage m(r);
if (m.getFinished())
TaskManager::onPreloadFinished();
break;
}
case constcrc("ConGenericMessage") :
{
ConGenericMessage taskConsoleCommand(r);
TaskManager::executeCommand(command);
static std::string command = taskConsoleCommand.getMsg();
while(command.rfind(' ') != command.npos || command.rfind('\n') != command.npos || command.rfind('\r') != command.npos)
{
command = command.substr(0, command.length() - 1);
}
TaskManager::executeCommand(command);
break;
}
}
}
@@ -10,6 +10,8 @@
#include "serverNetworkMessages/GameTaskManagerMessages.h"
#include "serverNetworkMessages/TaskSpawnProcess.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//-----------------------------------------------------------------------
DatabaseConnection::DatabaseConnection() :
@@ -42,17 +44,23 @@ void DatabaseConnection::receive(const Archive::ByteStream & message)
{
Archive::ReadIterator r(message);
GameNetworkMessage m(r);
r = message.begin();
if(m.isType("TaskSpawnProcess"))
{
TaskSpawnProcess s(r);
IGNORE_RETURN(TaskManager::startServer(s.getProcessName(), s.getOptions(), s.getTargetHostAddress(), s.getSpawnDelay()));
}
else if(m.isType("ServerIdleMessage"))
{
ServerIdleMessage msg(r);
TaskManager::onDatabaseIdle(msg.getIsIdle());
const uint32 messageType = m.getType();
switch(messageType) {
case constcrc("TaskSpawnProcess") :
{
TaskSpawnProcess s(r);
IGNORE_RETURN(TaskManager::startServer(s.getProcessName(), s.getOptions(), s.getTargetHostAddress(), s.getSpawnDelay()));
break;
}
case constcrc("ServerIdleMessage") :
{
ServerIdleMessage msg(r);
TaskManager::onDatabaseIdle(msg.getIsIdle());
break;
}
}
}
@@ -24,6 +24,8 @@
#include "TaskConnection.h"
#include "TaskManager.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//-----------------------------------------------------------------------
namespace ManagerConnectionNamespace
@@ -94,115 +96,126 @@ void ManagerConnection::onReceive(const Archive::ByteStream & message)
{
Archive::ReadIterator r(message);
GameNetworkMessage m(r);
r = message.begin();
if (m.isType("SystemTimeCheck"))
{
long const currentTime = static_cast<long>(::time(nullptr));
GenericValueTypeMessage<std::pair<std::string, long > > msg(r);
if (TaskManager::getNodeLabel() == "node0")
const uint32 messageType = m.getType();
switch(messageType) {
case constcrc("SystemTimeCheck") :
{
if ((std::max(currentTime, msg.getValue().second) - std::min(currentTime, msg.getValue().second)) > ConfigTaskManager::getMaximumClockDriftToleranceSeconds())
long const currentTime = static_cast<long>(::time(nullptr));
GenericValueTypeMessage<std::pair<std::string, long > > msg(r);
if (TaskManager::getNodeLabel() == "node0")
{
LOG("CustomerService", ("system_clock_mismatch:System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), remote TaskManager %s (%s) epoch (%ld)", (std::max(currentTime, msg.getValue().second) - std::min(currentTime, msg.getValue().second)), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), currentTime, msg.getValue().first.c_str(), getRemoteAddress().c_str(), msg.getValue().second));
// tell CentralServer about the system clock mismatch so it can report an alert to SOEMon
GenericValueTypeMessage<std::string> systemTimeMismatchMessage("SystemTimeMismatchNotification",
FormattedString<1024>().sprintf("%s: %s (%s) is off by %ld seconds", CalendarTime::convertEpochToTimeStringLocal(static_cast<time_t>(currentTime)).c_str(), msg.getValue().first.c_str(), getRemoteAddress().c_str(), (std::max(currentTime, msg.getValue().second) - std::min(currentTime, msg.getValue().second))));
TaskManager::sendToCentralServer(systemTimeMismatchMessage);
}
}
}
else if (m.isType("TaskConnectionIdMessage"))
{
static long const clockDriftFatalTimePeriod = static_cast<long>(TaskManager::getStartTime()) + ConfigTaskManager::getClockDriftFatalIntervalSeconds();
long const currentTime = static_cast<long>(::time(nullptr));
TaskConnectionIdMessage t(r);
WARNING_STRICT_FATAL(t.getServerType() != TaskConnectionIdMessage::TaskManager,
("ManagerConnection received wrong type identifier"));
WARNING_STRICT_FATAL(m_nodeLabel, ("Received new taskconnectionIdMessage with an already named connection"));
FATAL((ConfigTaskManager::getVerifyClusterName() && (TaskManager::getNodeLabel() == "node0") && (t.getServerType() == TaskConnectionIdMessage::TaskManager) && (t.getClusterName() != std::string(ConfigTaskManager::getClusterName()))), ("Remote TaskManager %s (%s) reported cluster name (%s) that is different from my cluster name (%s)", t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getClusterName().c_str(), ConfigTaskManager::getClusterName()));
// don't allow cluster to start if the system clock across the boxes are out of sync
bool remoteSystemClockInSync = true;
if (TaskManager::getNodeLabel() == "node0")
{
if ((std::max(currentTime, t.getCurrentEpochTime()) - std::min(currentTime, t.getCurrentEpochTime())) > ConfigTaskManager::getMaximumClockDriftToleranceSeconds())
{
remoteSystemClockInSync = false;
// don't bring down the cluster if we lost a box and when the box is
// restarted, its system clock is out of sync; just ignore that
// TaskManager, and send it a message to terminate itself
if (currentTime <= clockDriftFatalTimePeriod)
if ((std::max(currentTime, msg.getValue().second) - std::min(currentTime, msg.getValue().second)) > ConfigTaskManager::getMaximumClockDriftToleranceSeconds())
{
FATAL(true, ("System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), remote TaskManager %s (%s) epoch (%ld)", (std::max(currentTime, t.getCurrentEpochTime()) - std::min(currentTime, t.getCurrentEpochTime())), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), currentTime, t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getCurrentEpochTime()));
}
else
{
LOG("CustomerService", ("system_clock_mismatch:System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), remote TaskManager %s (%s) epoch (%ld). Telling remote TaskManager to terminate.", (std::max(currentTime, t.getCurrentEpochTime()) - std::min(currentTime, t.getCurrentEpochTime())), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), currentTime, t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getCurrentEpochTime()));
LOG("CustomerService", ("system_clock_mismatch:System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), remote TaskManager %s (%s) epoch (%ld)", (std::max(currentTime, msg.getValue().second) - std::min(currentTime, msg.getValue().second)), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), currentTime, msg.getValue().first.c_str(), getRemoteAddress().c_str(), msg.getValue().second));
GenericValueTypeMessage<std::pair<std::string, std::pair<long, long> > > systemTimeMismatchMessage("SystemTimeMismatchMessage", std::make_pair(TaskManager::getNodeLabel(), std::make_pair(static_cast<long>(currentTime), t.getCurrentEpochTime())));
send(systemTimeMismatchMessage);
}
}
}
if (remoteSystemClockInSync)
{
m_nodeLabel = new std::string(t.getCommandLine());
Locator::opened(*m_nodeLabel, this);
TaskManager::resendUnacknowledgedSpawnRequests(this, *m_nodeLabel);
}
}
else if (m.isType("SystemTimeMismatchMessage"))
{
GenericValueTypeMessage<std::pair<std::string, std::pair<long, long> > > msg(r);
FATAL((msg.getValue().first == "node0"), ("System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), self epoch (%ld)", (std::max(msg.getValue().second.first, msg.getValue().second.second) - std::min(msg.getValue().second.first, msg.getValue().second.second)), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), msg.getValue().second.first, msg.getValue().second.second));
}
else if(m.isType("TaskSpawnProcess"))
{
TaskSpawnProcess s(r);
if (TaskManager::startServer(s.getProcessName(), s.getOptions(), s.getTargetHostAddress(), s.getSpawnDelay()) == 0)
{
DEBUG_REPORT_LOG(true, ("Failed to spawn %s on this node\n", s.getProcessName().c_str()));
//send fail message back
}
else
{
TaskSpawnProcessAck ack(s.getTransactionId());
send(ack);
}
}
else if(m.isType("TaskUtilization"))
{
TaskUtilization util(r);
switch(util.getUtilType())
{
case TaskUtilization::SYSTEM_AVG:
{
if (m_nodeLabel)
{
m_remoteUtilAvg = util.getUtilAmount();
Locator::updateServerLoad(*m_nodeLabel, m_remoteUtilAvg);
// tell CentralServer about the system clock mismatch so it can report an alert to SOEMon
GenericValueTypeMessage<std::string> systemTimeMismatchMessage("SystemTimeMismatchNotification",
FormattedString<1024>().sprintf("%s: %s (%s) is off by %ld seconds", CalendarTime::convertEpochToTimeStringLocal(static_cast<time_t>(currentTime)).c_str(), msg.getValue().first.c_str(), getRemoteAddress().c_str(), (std::max(currentTime, msg.getValue().second) - std::min(currentTime, msg.getValue().second))));
TaskManager::sendToCentralServer(systemTimeMismatchMessage);
}
}
break;
default:
}
case constcrc("TaskConnectionIdMessage") :
{
static long const clockDriftFatalTimePeriod = static_cast<long>(TaskManager::getStartTime()) + ConfigTaskManager::getClockDriftFatalIntervalSeconds();
long const currentTime = static_cast<long>(::time(nullptr));
TaskConnectionIdMessage t(r);
WARNING_STRICT_FATAL(t.getServerType() != TaskConnectionIdMessage::TaskManager,
("ManagerConnection received wrong type identifier"));
WARNING_STRICT_FATAL(m_nodeLabel, ("Received new taskconnectionIdMessage with an already named connection"));
FATAL((ConfigTaskManager::getVerifyClusterName() && (TaskManager::getNodeLabel() == "node0") && (t.getServerType() == TaskConnectionIdMessage::TaskManager) && (t.getClusterName() != std::string(ConfigTaskManager::getClusterName()))), ("Remote TaskManager %s (%s) reported cluster name (%s) that is different from my cluster name (%s)", t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getClusterName().c_str(), ConfigTaskManager::getClusterName()));
// don't allow cluster to start if the system clock across the boxes are out of sync
bool remoteSystemClockInSync = true;
if (TaskManager::getNodeLabel() == "node0")
{
if ((std::max(currentTime, t.getCurrentEpochTime()) - std::min(currentTime, t.getCurrentEpochTime())) > ConfigTaskManager::getMaximumClockDriftToleranceSeconds())
{
remoteSystemClockInSync = false;
// don't bring down the cluster if we lost a box and when the box is
// restarted, its system clock is out of sync; just ignore that
// TaskManager, and send it a message to terminate itself
if (currentTime <= clockDriftFatalTimePeriod)
{
FATAL(true, ("System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), remote TaskManager %s (%s) epoch (%ld)", (std::max(currentTime, t.getCurrentEpochTime()) - std::min(currentTime, t.getCurrentEpochTime())), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), currentTime, t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getCurrentEpochTime()));
}
else
{
LOG("CustomerService", ("system_clock_mismatch:System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), remote TaskManager %s (%s) epoch (%ld). Telling remote TaskManager to terminate.", (std::max(currentTime, t.getCurrentEpochTime()) - std::min(currentTime, t.getCurrentEpochTime())), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), currentTime, t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getCurrentEpochTime()));
GenericValueTypeMessage<std::pair<std::string, std::pair<long, long> > > systemTimeMismatchMessage("SystemTimeMismatchMessage", std::make_pair(TaskManager::getNodeLabel(), std::make_pair(static_cast<long>(currentTime), t.getCurrentEpochTime())));
send(systemTimeMismatchMessage);
}
}
}
if (remoteSystemClockInSync)
{
m_nodeLabel = new std::string(t.getCommandLine());
Locator::opened(*m_nodeLabel, this);
TaskManager::resendUnacknowledgedSpawnRequests(this, *m_nodeLabel);
}
break;
}
case constcrc("SystemTimeMismatchMessage") :
{
GenericValueTypeMessage<std::pair<std::string, std::pair<long, long> > > msg(r);
FATAL((msg.getValue().first == "node0"), ("System clock mismatch (%d seconds) by more than %d seconds: master TaskManager epoch (%ld), self epoch (%ld)", (std::max(msg.getValue().second.first, msg.getValue().second.second) - std::min(msg.getValue().second.first, msg.getValue().second.second)), ConfigTaskManager::getMaximumClockDriftToleranceSeconds(), msg.getValue().second.first, msg.getValue().second.second));
break;
}
case constcrc("TaskSpawnProcess") :
{
TaskSpawnProcess s(r);
if (TaskManager::startServer(s.getProcessName(), s.getOptions(), s.getTargetHostAddress(), s.getSpawnDelay()) == 0)
{
DEBUG_REPORT_LOG(true, ("Failed to spawn %s on this node\n", s.getProcessName().c_str()));
//send fail message back
}
else
{
TaskSpawnProcessAck ack(s.getTransactionId());
send(ack);
}
break;
}
case constcrc("TaskUtilization") :
{
TaskUtilization util(r);
switch(util.getUtilType())
{
case TaskUtilization::SYSTEM_AVG:
{
if (m_nodeLabel)
{
m_remoteUtilAvg = util.getUtilAmount();
Locator::updateServerLoad(*m_nodeLabel, m_remoteUtilAvg);
}
}
break;
default:
break;
}
break;
}
case constcrc("TaskProcessDiedMessage") :
{
TaskProcessDiedMessage died(r);
TaskManager::sendToCentralServer(died);
break;
}
case constcrc("TaskSpawnProcessAck") :
{
TaskSpawnProcessAck ack(r);
TaskManager::removePendingSpawnProcessAck(ack.getTransactionId());
break;
}
}
else if(m.isType("TaskProcessDiedMessage"))
{
TaskProcessDiedMessage died(r);
TaskManager::sendToCentralServer(died);
}
else if(m.isType("TaskSpawnProcessAck"))
{
TaskSpawnProcessAck ack(r);
TaskManager::removePendingSpawnProcessAck(ack.getTransactionId());
}
}
@@ -20,6 +20,8 @@
#include "serverNetworkMessages/TaskKillProcess.h"
#include "sharedNetwork/NetworkSetupData.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//-----------------------------------------------------------------------
TaskConnection::TaskConnection(const std::string & a, const unsigned short p) :
@@ -94,70 +96,79 @@ void TaskConnection::onReceive(const Archive::ByteStream & message)
Archive::ReadIterator r(message);
GameNetworkMessage m(r);
if(m.isType("TaskConnectionIdMessage"))
{
r = message.begin();
TaskConnectionIdMessage t(r);
FATAL((ConfigTaskManager::getVerifyClusterName() && (TaskManager::getNodeLabel() == "node0") && (t.getServerType() == TaskConnectionIdMessage::TaskManager) && (t.getClusterName() != std::string(ConfigTaskManager::getClusterName()))), ("Remote TaskManager %s (%s) reported cluster name (%s) that is different from my cluster name (%s)", t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getClusterName().c_str(), ConfigTaskManager::getClusterName()));
Identified i = {this, t.getServerType() };
identified.emitMessage(i);
switch(i.id)
const uint32 messageType = m.getType();
switch(messageType) {
case constcrc("TaskConnectionIdMessage") :
{
case TaskConnectionIdMessage::Central:
{
REPORT_LOG(true, ("New Central Server connection active\n"));
handler = new CentralConnection(this, t.getCommandLine());
TaskManager::setCentralConnection(this);
}
break;
case TaskConnectionIdMessage::Game:
{
REPORT_LOG(true, ("New Game Server connection active\n"));
handler = new GameConnection(this);
}
break;
case TaskConnectionIdMessage::Database:
{
REPORT_LOG(true, ("New Database Server connection active\n"));
handler = new DatabaseConnection();
}
break;
case TaskConnectionIdMessage::Metrics:
{
REPORT_LOG(true, ("New Metrics Server connection active\n"));
handler = new MetricsServerConnection(this, t.getCommandLine());
}
break;
case TaskConnectionIdMessage::Planet:
{
REPORT_LOG(true, ("New Planet Server connection active\n"));
handler = new PlanetConnection(this);
}
break;
r = message.begin();
TaskConnectionIdMessage t(r);
default:
WARNING_STRICT_FATAL(true, ("Unknown id (%d) received on task connection", i.id));
FATAL((ConfigTaskManager::getVerifyClusterName() && (TaskManager::getNodeLabel() == "node0") && (t.getServerType() == TaskConnectionIdMessage::TaskManager) && (t.getClusterName() != std::string(ConfigTaskManager::getClusterName()))), ("Remote TaskManager %s (%s) reported cluster name (%s) that is different from my cluster name (%s)", t.getCommandLine().c_str(), getRemoteAddress().c_str(), t.getClusterName().c_str(), ConfigTaskManager::getClusterName()));
Identified i = {this, t.getServerType() };
identified.emitMessage(i);
switch(i.id)
{
case TaskConnectionIdMessage::Central:
{
REPORT_LOG(true, ("New Central Server connection active\n"));
handler = new CentralConnection(this, t.getCommandLine());
TaskManager::setCentralConnection(this);
}
break;
case TaskConnectionIdMessage::Game:
{
REPORT_LOG(true, ("New Game Server connection active\n"));
handler = new GameConnection(this);
}
break;
case TaskConnectionIdMessage::Database:
{
REPORT_LOG(true, ("New Database Server connection active\n"));
handler = new DatabaseConnection();
}
break;
case TaskConnectionIdMessage::Metrics:
{
REPORT_LOG(true, ("New Metrics Server connection active\n"));
handler = new MetricsServerConnection(this, t.getCommandLine());
}
break;
case TaskConnectionIdMessage::Planet:
{
REPORT_LOG(true, ("New Planet Server connection active\n"));
handler = new PlanetConnection(this);
}
break;
default:
WARNING_STRICT_FATAL(true, ("Unknown id (%d) received on task connection", i.id));
break;
}
break;
}
case constcrc("ExcommunicateGameServerMessage") :
{
r = message.begin();
ExcommunicateGameServerMessage ex(r);
TaskKillProcess k(ex.getHostName(), ex.getProcessId(), true);
TaskManager::killProcess(k);
// broadcast to other task managers
Locator::sendToAllTaskManagers(k);
break;
}
case constcrc("TaskKillProcess") :
{
r = message.begin();
TaskKillProcess k(r);
TaskManager::killProcess(k);
break;
}
}
else if(m.isType("ExcommunicateGameServerMessage"))
{
r = message.begin();
ExcommunicateGameServerMessage ex(r);
TaskKillProcess k(ex.getHostName(), ex.getProcessId(), true);
TaskManager::killProcess(k);
// broadcast to other task managers
Locator::sendToAllTaskManagers(k);
}
else if(m.isType("TaskKillProcess"))
{
r = message.begin();
TaskKillProcess k(r);
TaskManager::killProcess(k);
}
msg.message = &message;
@@ -25,6 +25,8 @@
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
#include "UnicodeUtils.h"
#include "sharedFoundation/CrcConstexpr.hpp"
//-----------------------------------------------------------------------
namespace CentralServerConnectionNamespace
@@ -95,306 +97,329 @@ void CentralServerConnection::onReceive(const Archive::ByteStream & message)
Archive::ReadIterator ri = message.begin();
const GameNetworkMessage msg(ri);
ri = message.begin();
if(msg.isType("CentralGalaxyName"))
{
const GenericValueTypeMessage<std::string> cgn(ri);
setGalaxyName(cgn.getValue());
LOG("CustomerService", ("CharacterTransfer: Received CentralGalaxyName for %s", cgn.getValue().c_str()));
}
else if(msg.isType("UploadCharacterMessage"))
{
// receiving character data
const UploadCharacterMessage ucm(ri);
CharacterTransferData data;
data.stationId = ucm.getStationId();
data.fromGalaxy = m_galaxyName;
data.packedData = ucm.getPackedCharacterData();
bool result = TransferServer::uploadCharacterTransferData(data, ucm.getIsAdmin());
if(result)
const uint32 messageType = msg.getType();
switch(messageType) {
case constcrc("CentralGalaxyName") :
{
CharacterTransferStatusMessage uploadResult(ucm.getFromGameServerId(), ucm.getFromCharacterId(), "@base_player:upload_success");
send(uploadResult, true);
const GenericValueTypeMessage<std::string> cgn(ri);
setGalaxyName(cgn.getValue());
LOG("CustomerService", ("CharacterTransfer: Received CentralGalaxyName for %s", cgn.getValue().c_str()));
break;
}
else
case constcrc("UploadCharacterMessage") :
{
CharacterTransferStatusMessage uploadResult(ucm.getFromGameServerId(), ucm.getFromCharacterId(), "@base_player:upload_fail");
send(uploadResult, true);
}
}
else if(msg.isType("DownloadCharacterMessage"))
{
// retreive packed data from transfer server and
// send it to the requesting central server
const DownloadCharacterMessage dcm(ri);
const CharacterTransferData * data = TransferServer::getCharacterTransferData(dcm.getStationId(), m_galaxyName, dcm.getIsAdmin());
if(data)
{
const UploadCharacterMessage ucm(data->stationId, data->packedData, dcm.getGameServerId(), dcm.getToCharacterId(), true);
send(ucm, true);
LOG("CustomerService", ("CharacterTransfer: Character data for SUID %d downloaded\n", data->stationId));
}
else
{
CharacterTransferStatusMessage downloadResult(dcm.getGameServerId(), dcm.getToCharacterId(), "@base_player:download_fail");
send(downloadResult, true);
}
}
else if(msg.isType("AuthorizeDownload"))
{
const GenericValueTypeMessage<unsigned int> auth(ri);
TransferServer::authorizeDownload(auth.getValue());
}
else if(msg.isType("UnauthorizeDownload"))
{
const GenericValueTypeMessage<unsigned int> auth(ri);
TransferServer::unauthorizeDownload(auth.getValue());
}
else if(msg.isType("TransferReplyCharacterList"))
{
const TransferReplyCharacterList reply(ri);
// TESTING!
LOG("CustomerService", ("CharacterTransfer: Received character list for station id %d\n", reply.getStationId()));
const std::vector<AvatarRecord> & avatarList = reply.getAvatarList();
std::vector<AvatarRecord>::const_iterator i;
LOG("CustomerService", ("CharacterTransfer: Enumerating %d characters", avatarList.size()));
for(i = avatarList.begin() ; i != avatarList.end(); ++i)
{
LOG("CustomerService", ("CharacterTransfer: m_name = \"%s\" m_networkId = %s\n", Unicode::wideToNarrow(i->m_name).c_str(), i->m_networkId.getValueString().c_str()));
}
// TESTING END
TransferServer::replyCharacterList(reply);
}
else if(msg.isType("TransferReplyMoveValidation"))
{
const TransferReplyMoveValidation reply(ri);
if(reply.getResult() == TransferReplyMoveValidation::TRMVR_can_create_regular_character)
{
// save off the source character's template crc so it can be used in
// subsequent TransferRequestMoveValidation queries, so the LoginServer
// doesn't have to continually query the DB to fetch the same information
// over and over again, because the character's template crc
// (i.e. the character's species) should never, ever change
TransferServer::cacheSourceCharacterTemplateCrc(reply.getSourceStationId(), reply.getSourceGalaxy(), reply.getSourceCharacter(), reply.getSourceCharacterTemplateId());
TransferCharacterData requestData(reply.getTransferRequestSource());
requestData.setTrack(reply.getTrack());
requestData.setCustomerLocalizedLanguage(reply.getCustomerLocalizedLanguage());
requestData.setSourceGalaxy(reply.getSourceGalaxy());
requestData.setDestinationGalaxy(reply.getDestinationGalaxy());
requestData.setSourceCharacterName(reply.getSourceCharacter());
requestData.setObjectTemplateCrc(reply.getSourceCharacterTemplateId());
requestData.setDestinationCharacterName(reply.getDestinationCharacter());
requestData.setSourceStationId(reply.getSourceStationId());
requestData.setDestinationStationId(reply.getDestinationStationId());
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation("TransferRequestNameValidation", requestData);
CentralServerConnection * destinationConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getDestinationGalaxy());
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyMoveValidation for %s on %s to %s on %s from CentralServer. Sending TransferRequestNameValidation to destination CentralServer.", reply.getSourceCharacter().c_str(), reply.getSourceGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getDestinationGalaxy().c_str()));
const GenericValueTypeMessage<std::pair<unsigned int, unsigned int> > kick("TransferRequestKickConnectedClients", std::make_pair(requestData.getSourceStationId(), requestData.getDestinationStationId()));
if(destinationConnection)
// receiving character data
const UploadCharacterMessage ucm(ri);
CharacterTransferData data;
data.stationId = ucm.getStationId();
data.fromGalaxy = m_galaxyName;
data.packedData = ucm.getPackedCharacterData();
bool result = TransferServer::uploadCharacterTransferData(data, ucm.getIsAdmin());
if(result)
{
destinationConnection->send(requestNameValidation, true);
destinationConnection->send(kick, true);
CharacterTransferStatusMessage uploadResult(ucm.getFromGameServerId(), ucm.getFromCharacterId(), "@base_player:upload_success");
send(uploadResult, true);
}
CentralServerConnection * sourceConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getSourceGalaxy());
if(sourceConnection)
else
{
sourceConnection->send(kick, true);
CharacterTransferStatusMessage uploadResult(ucm.getFromGameServerId(), ucm.getFromCharacterId(), "@base_player:upload_fail");
send(uploadResult, true);
}
break;
}
else
case constcrc("DownloadCharacterMessage") :
{
LOG("CustomerService", ("CharacterTransfer: TransferReplyMoveValidation failed for %s on %s to %s on %s from CentralServer because the account cannot create a new character on the destination server", reply.getSourceCharacter().c_str(), reply.getSourceGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getDestinationGalaxy().c_str()));
TransferServer::failedToValidateTransfer(reply);
}
}
else if(msg.isType("TransferReplyNameValidation"))
{
const GenericValueTypeMessage<std::pair<std::string, TransferCharacterData> > replyNameValidation(ri);
if(!replyNameValidation.getValue().second.getIsMoveRequest())
{
LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for move validation request. (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str()));
TransferServer::replyValidateMove(replyNameValidation.getValue().second);
}
else
{
if(TransferServer::isRename(replyNameValidation.getValue().second))
// retreive packed data from transfer server and
// send it to the requesting central server
const DownloadCharacterMessage dcm(ri);
const CharacterTransferData * data = TransferServer::getCharacterTransferData(dcm.getStationId(), m_galaxyName, dcm.getIsAdmin());
if(data)
{
LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for rename request, starting character rename protocol. (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str()));
const GenericValueTypeMessage<TransferCharacterData> renameCharacter("TransferRenameCharacter", replyNameValidation.getValue().second);
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(replyNameValidation.getValue().second.getSourceGalaxy());
if(centralServerConnection)
const UploadCharacterMessage ucm(data->stationId, data->packedData, dcm.getGameServerId(), dcm.getToCharacterId(), true);
send(ucm, true);
LOG("CustomerService", ("CharacterTransfer: Character data for SUID %d downloaded\n", data->stationId));
}
else
{
CharacterTransferStatusMessage downloadResult(dcm.getGameServerId(), dcm.getToCharacterId(), "@base_player:download_fail");
send(downloadResult, true);
}
break;
}
case constcrc("AuthorizeDownload") :
{
const GenericValueTypeMessage<unsigned int> auth(ri);
TransferServer::authorizeDownload(auth.getValue());
break;
}
case constcrc("UnauthorizeDownload") :
{
const GenericValueTypeMessage<unsigned int> auth(ri);
TransferServer::unauthorizeDownload(auth.getValue());
break;
}
case constcrc("TransferReplyCharacterList") :
{
const TransferReplyCharacterList reply(ri);
// TESTING!
LOG("CustomerService", ("CharacterTransfer: Received character list for station id %d\n", reply.getStationId()));
const std::vector<AvatarRecord> & avatarList = reply.getAvatarList();
std::vector<AvatarRecord>::const_iterator i;
LOG("CustomerService", ("CharacterTransfer: Enumerating %d characters", avatarList.size()));
for(i = avatarList.begin() ; i != avatarList.end(); ++i)
{
LOG("CustomerService", ("CharacterTransfer: m_name = \"%s\" m_networkId = %s\n", Unicode::wideToNarrow(i->m_name).c_str(), i->m_networkId.getValueString().c_str()));
}
// TESTING END
TransferServer::replyCharacterList(reply);
break;
}
case constcrc("TransferReplyMoveValidation") :
{
const TransferReplyMoveValidation reply(ri);
if(reply.getResult() == TransferReplyMoveValidation::TRMVR_can_create_regular_character)
{
// save off the source character's template crc so it can be used in
// subsequent TransferRequestMoveValidation queries, so the LoginServer
// doesn't have to continually query the DB to fetch the same information
// over and over again, because the character's template crc
// (i.e. the character's species) should never, ever change
TransferServer::cacheSourceCharacterTemplateCrc(reply.getSourceStationId(), reply.getSourceGalaxy(), reply.getSourceCharacter(), reply.getSourceCharacterTemplateId());
TransferCharacterData requestData(reply.getTransferRequestSource());
requestData.setTrack(reply.getTrack());
requestData.setCustomerLocalizedLanguage(reply.getCustomerLocalizedLanguage());
requestData.setSourceGalaxy(reply.getSourceGalaxy());
requestData.setDestinationGalaxy(reply.getDestinationGalaxy());
requestData.setSourceCharacterName(reply.getSourceCharacter());
requestData.setObjectTemplateCrc(reply.getSourceCharacterTemplateId());
requestData.setDestinationCharacterName(reply.getDestinationCharacter());
requestData.setSourceStationId(reply.getSourceStationId());
requestData.setDestinationStationId(reply.getDestinationStationId());
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation("TransferRequestNameValidation", requestData);
CentralServerConnection * destinationConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getDestinationGalaxy());
LOG("CustomerService", ("CharacterTransfer: Received TransferReplyMoveValidation for %s on %s to %s on %s from CentralServer. Sending TransferRequestNameValidation to destination CentralServer.", reply.getSourceCharacter().c_str(), reply.getSourceGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getDestinationGalaxy().c_str()));
const GenericValueTypeMessage<std::pair<unsigned int, unsigned int> > kick("TransferRequestKickConnectedClients", std::make_pair(requestData.getSourceStationId(), requestData.getDestinationStationId()));
if(destinationConnection)
{
centralServerConnection->send(renameCharacter, true);
destinationConnection->send(requestNameValidation, true);
destinationConnection->send(kick, true);
}
else
CentralServerConnection * sourceConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getSourceGalaxy());
if(sourceConnection)
{
TransferServer::transferCreateCharacterFailed(replyNameValidation.getValue().second);
sourceConnection->send(kick, true);
}
}
else
{
DEBUG_FATAL(true, ("Received TransferReplyNameValidation for a move request that is not a rename!"));
LOG("CustomerService", ("CharacterTransfer: TransferReplyMoveValidation failed for %s on %s to %s on %s from CentralServer because the account cannot create a new character on the destination server", reply.getSourceCharacter().c_str(), reply.getSourceGalaxy().c_str(), reply.getDestinationCharacter().c_str(), reply.getDestinationGalaxy().c_str()));
TransferServer::failedToValidateTransfer(reply);
}
break;
}
}
else if(msg.isType("TransferReplyCharacterDataFromLoginServer"))
{
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Got TransferReplyCharacterDataFromLoginServer, characterId=%s\n", reply.getValue().getCharacterId().getValueString().c_str()));
// is this a transfer or a rename?
if(TransferServer::isRename(reply.getValue()))
case constcrc("TransferReplyNameValidation") :
{
LOG("CustomerService", ("CharacterTransfer: Sending TransferRequestNameValidation for character rename request: %s", reply.getValue().toString().c_str()));
// send a name validation request
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation("TransferRequestNameValidation", reply.getValue());
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getValue().getSourceGalaxy());
const GenericValueTypeMessage<std::pair<std::string, TransferCharacterData> > replyNameValidation(ri);
if(!replyNameValidation.getValue().second.getIsMoveRequest())
{
LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for move validation request. (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str()));
TransferServer::replyValidateMove(replyNameValidation.getValue().second);
}
else
{
if(TransferServer::isRename(replyNameValidation.getValue().second))
{
LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for rename request, starting character rename protocol. (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str()));
const GenericValueTypeMessage<TransferCharacterData> renameCharacter("TransferRenameCharacter", replyNameValidation.getValue().second);
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(replyNameValidation.getValue().second.getSourceGalaxy());
if(centralServerConnection)
{
centralServerConnection->send(renameCharacter, true);
}
else
{
TransferServer::transferCreateCharacterFailed(replyNameValidation.getValue().second);
}
}
else
{
DEBUG_FATAL(true, ("Received TransferReplyNameValidation for a move request that is not a rename!"));
}
}
break;
}
case constcrc("TransferReplyCharacterDataFromLoginServer") :
{
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Got TransferReplyCharacterDataFromLoginServer, characterId=%s\n", reply.getValue().getCharacterId().getValueString().c_str()));
// is this a transfer or a rename?
if(TransferServer::isRename(reply.getValue()))
{
LOG("CustomerService", ("CharacterTransfer: Sending TransferRequestNameValidation for character rename request: %s", reply.getValue().toString().c_str()));
// send a name validation request
const GenericValueTypeMessage<TransferCharacterData> requestNameValidation("TransferRequestNameValidation", reply.getValue());
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(reply.getValue().getSourceGalaxy());
if(centralServerConnection)
{
centralServerConnection->send(requestNameValidation, true);
}
}
else
{
// this is a transfer
TransferServer::getLoginLocationData(reply.getValue());
}
break;
}
case constcrc("TransferReplyLoginLocationData") :
{
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Got TransferReplyLoginLocationData from CentralServer. TransferCharacterData=%s\n", reply.getValue().toString().c_str()));
// send character to ConnectionServer for login to a game server
const GenericValueTypeMessage<TransferCharacterData> login("TransferLoginCharacterToSourceServer", reply.getValue());
LOG("CustomerService", ("CharacterTransfer: Sending TransferLoginCharacterToSourceServer to CentralServer : %s", login.getValue().toString().c_str()));
send(login, true);
break;
}
case constcrc("TransferReceiveDataFromGameServer") :
{
const GenericValueTypeMessage<TransferCharacterData> transferReply(ri);
LOG("CustomerService", ("CharacterTransfer: Got TransferReceiveDataFromGameServer: %s", transferReply.getValue().toString().c_str()));
REPORT_LOG(true, ("Got TransferReceiveDataFromGameServer: %s\n", transferReply.getValue().toString().c_str()));
// find a central server connection for the target cluster
CentralServerConnection * destinationCentralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(transferReply.getValue().getDestinationGalaxy());
if(destinationCentralConnection)
{
// send character to ConnectionServer for creation on the destination server
GenericValueTypeMessage<TransferCharacterData> login("TransferLoginCharacterToDestinationServer", transferReply.getValue());
destinationCentralConnection->send(login, true);
LOG("CustomerService", ("CharacterTransfer: Sending TransferLoginCharacterToDestinationServer to CentralServer (%s) for (%s)", transferReply.getValue().getDestinationGalaxy().c_str(), login.getValue().toString().c_str()));
}
else
{
//@todo: report error to CTS API
LOG("CustomerService", ("CharacterTransfer: Failed to get a CentralServer connection for %s", transferReply.getValue().getDestinationGalaxy().c_str()));
TransferServer::transferCreateCharacterFailed(transferReply.getValue());
}
break;
}
case constcrc("ApplyTransferDataSuccess") :
{
const GenericValueTypeMessage<TransferCharacterData> success(ri);
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataSuccess from target galaxy. %s", success.getValue().toString().c_str()));
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(success.getValue().getSourceGalaxy());
if(centralServerConnection)
{
centralServerConnection->send(requestNameValidation, true);
LOG("CustomerService", ("CharacterTransfer: Sending ToggleAvatarLoginStatus request to source central server"));
const ToggleAvatarLoginStatus toggleLoginStatus(success.getValue().getSourceGalaxy(), success.getValue().getSourceStationId(), success.getValue().getCharacterId(), false);
centralServerConnection->send(toggleLoginStatus, true);
TransferServer::replyMoveSuccess(success.getValue());
LOG("CustomerService", ("CharacterTransfer: TRANSFER SUCCESSFUL for transactionId=%u", success.getValue().getTransactionId()));
}
else
{
LOG("CustomerService", ("CharacterTransfer: Transfer failed on target galaxy : %s", success.getValue().toString().c_str()));
TransferServer::transferCreateCharacterFailed(success.getValue());
}
break;
}
else
case constcrc("ApplyTransferDataFail") :
{
// this is a transfer
TransferServer::getLoginLocationData(reply.getValue());
}
}
else if(msg.isType("TransferReplyLoginLocationData"))
{
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Got TransferReplyLoginLocationData from CentralServer. TransferCharacterData=%s\n", reply.getValue().toString().c_str()));
// send character to ConnectionServer for login to a game server
const GenericValueTypeMessage<TransferCharacterData> login("TransferLoginCharacterToSourceServer", reply.getValue());
LOG("CustomerService", ("CharacterTransfer: Sending TransferLoginCharacterToSourceServer to CentralServer : %s", login.getValue().toString().c_str()));
send(login, true);
}
else if(msg.isType("TransferReceiveDataFromGameServer"))
{
const GenericValueTypeMessage<TransferCharacterData> transferReply(ri);
LOG("CustomerService", ("CharacterTransfer: Got TransferReceiveDataFromGameServer: %s", transferReply.getValue().toString().c_str()));
REPORT_LOG(true, ("Got TransferReceiveDataFromGameServer: %s\n", transferReply.getValue().toString().c_str()));
// find a central server connection for the target cluster
CentralServerConnection * destinationCentralConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(transferReply.getValue().getDestinationGalaxy());
if(destinationCentralConnection)
{
// send character to ConnectionServer for creation on the destination server
GenericValueTypeMessage<TransferCharacterData> login("TransferLoginCharacterToDestinationServer", transferReply.getValue());
destinationCentralConnection->send(login, true);
LOG("CustomerService", ("CharacterTransfer: Sending TransferLoginCharacterToDestinationServer to CentralServer (%s) for (%s)", transferReply.getValue().getDestinationGalaxy().c_str(), login.getValue().toString().c_str()));
}
else
{
//@todo: report error to CTS API
LOG("CustomerService", ("CharacterTransfer: Failed to get a CentralServer connection for %s", transferReply.getValue().getDestinationGalaxy().c_str()));
TransferServer::transferCreateCharacterFailed(transferReply.getValue());
}
}
else if(msg.isType("ApplyTransferDataSuccess"))
{
const GenericValueTypeMessage<TransferCharacterData> success(ri);
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataSuccess from target galaxy. %s", success.getValue().toString().c_str()));
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(success.getValue().getSourceGalaxy());
if(centralServerConnection)
{
LOG("CustomerService", ("CharacterTransfer: Sending ToggleAvatarLoginStatus request to source central server"));
const ToggleAvatarLoginStatus toggleLoginStatus(success.getValue().getSourceGalaxy(), success.getValue().getSourceStationId(), success.getValue().getCharacterId(), false);
centralServerConnection->send(toggleLoginStatus, true);
TransferServer::replyMoveSuccess(success.getValue());
LOG("CustomerService", ("CharacterTransfer: TRANSFER SUCCESSFUL for transactionId=%u", success.getValue().getTransactionId()));
}
else
{
LOG("CustomerService", ("CharacterTransfer: Transfer failed on target galaxy : %s", success.getValue().toString().c_str()));
TransferServer::transferCreateCharacterFailed(success.getValue());
}
}
else if(msg.isType("ApplyTransferDataFail"))
{
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataFail from target galaxy. %s", fail.getValue().toString().c_str()));
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(fail.getValue().getDestinationGalaxy());
if(centralServerConnection)
{
LOG("CustomerService", ("CharacterTransfer: failed to apply transfer data. Deleting character on destination server. %s", fail.getValue().toString().c_str()));
const GenericValueTypeMessage<TransferCharacterData> deleteCharacter("DeleteFailedTransfer", fail.getValue());
centralServerConnection->send(deleteCharacter, true);
TransferServer::failedToApplyTransferData(fail.getValue());
}
}
else if(msg.isType("TransferCreateCharacterFailed"))
{
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferCreateCharacterFailed, sending response to CTS API. %s", fail.getValue().toString().c_str()));
TransferServer::transferCreateCharacterFailed(fail.getValue());
}
else if(msg.isType("TransferRenameCharacterReply"))
{
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacterReply from Central Server : %s", reply.getValue().toString().c_str()));
if(reply.getValue().getIsValidName())
{
TransferServer::replyMoveSuccess(reply.getValue());
}
else
{
TransferServer::transferCreateCharacterFailed(reply.getValue());
}
}
else if(msg.isType("TransferAccountReplySuccessTransferServer"))
{
const GenericValueTypeMessage<TransferAccountData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountReplySuccessTransferServer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
TransferServer::replyTransferAccountSuccess(reply.getValue());
}
else if(msg.isType("TransferAccountFailedToUpdateGameDatabase"))
{
const GenericValueTypeMessage<TransferAccountData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedToUpdateGameDatabase for transfer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
TransferServer::failedToTransferAccountNoCentralConnection(reply.getValue());
}
else if(msg.isType("TransferAccountFailedDestinationNotEmpty"))
{
const GenericValueTypeMessage<TransferAccountData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedDestinationNotEmpty for transfer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
TransferServer::failedToTransferAccountDestinationNotEmpty(reply.getValue());
}
else if(msg.isType("ReplyTransferDataFail"))
{
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
TransferServer::failedToRetrieveTransferData(reply.getValue());
}
else if(msg.isType("TransferFailGameServerClosedConnectionWithConnectionServer"))
{
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
TransferServer::failedToTransferCharacterGameConnectionClosed(fail.getValue());
}
else if(msg.isType("TransferFailConnectionServerClosedConnectionWithCentralServer"))
{
const GenericValueTypeMessage<unsigned int> fail(ri);
TransferServer::failedToTransferCharacterConnectionServerConnectionClosed(fail.getValue());
}
else if(msg.isType("ConGenericMessage"))
{
const ConGenericMessage cm(ri);
std::string result;
ConsoleManager::processString(cm.getMsg(), static_cast<const NetworkId::NetworkIdType>(cm.getMsgId()), result);
const ConGenericMessage response(result, cm.getMsgId());
send(response, true);
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
LOG("CustomerService", ("CharacterTransfer: Received ApplyTransferDataFail from target galaxy. %s", fail.getValue().toString().c_str()));
CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(fail.getValue().getDestinationGalaxy());
if(centralServerConnection)
{
LOG("CustomerService", ("CharacterTransfer: failed to apply transfer data. Deleting character on destination server. %s", fail.getValue().toString().c_str()));
const GenericValueTypeMessage<TransferCharacterData> deleteCharacter("DeleteFailedTransfer", fail.getValue());
centralServerConnection->send(deleteCharacter, true);
TransferServer::failedToApplyTransferData(fail.getValue());
}
break;
}
case constcrc("TransferCreateCharacterFailed") :
{
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferCreateCharacterFailed, sending response to CTS API. %s", fail.getValue().toString().c_str()));
TransferServer::transferCreateCharacterFailed(fail.getValue());
break;
}
case constcrc("TransferRenameCharacterReply") :
{
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacterReply from Central Server : %s", reply.getValue().toString().c_str()));
if(reply.getValue().getIsValidName())
{
TransferServer::replyMoveSuccess(reply.getValue());
}
else
{
TransferServer::transferCreateCharacterFailed(reply.getValue());
}
break;
}
case constcrc("TransferAccountReplySuccessTransferServer") :
{
const GenericValueTypeMessage<TransferAccountData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountReplySuccessTransferServer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
TransferServer::replyTransferAccountSuccess(reply.getValue());
break;
}
case constcrc("TransferAccountFailedToUpdateGameDatabase") :
{
const GenericValueTypeMessage<TransferAccountData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedToUpdateGameDatabase for transfer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
TransferServer::failedToTransferAccountNoCentralConnection(reply.getValue());
break;
}
case constcrc("TransferAccountFailedDestinationNotEmpty") :
{
const GenericValueTypeMessage<TransferAccountData> reply(ri);
LOG("CustomerService", ("CharacterTransfer: Received TransferAccountFailedDestinationNotEmpty for transfer from station Id %d to station Id %d", reply.getValue().getSourceStationId(), reply.getValue().getDestinationStationId()));
TransferServer::failedToTransferAccountDestinationNotEmpty(reply.getValue());
break;
}
case constcrc("ReplyTransferDataFail") :
{
const GenericValueTypeMessage<TransferCharacterData> reply(ri);
TransferServer::failedToRetrieveTransferData(reply.getValue());
break;
}
case constcrc("TransferFailGameServerClosedConnectionWithConnectionServer") :
{
const GenericValueTypeMessage<TransferCharacterData> fail(ri);
TransferServer::failedToTransferCharacterGameConnectionClosed(fail.getValue());
break;
}
case constcrc("TransferFailConnectionServerClosedConnectionWithCentralServer") :
{
const GenericValueTypeMessage<unsigned int> fail(ri);
TransferServer::failedToTransferCharacterConnectionServerConnectionClosed(fail.getValue());
break;
}
case constcrc("ConGenericMessage") :
{
const ConGenericMessage cm(ri);
std::string result;
ConsoleManager::processString(cm.getMsg(), static_cast<const NetworkId::NetworkIdType>(cm.getMsgId()), result);
const ConGenericMessage response(result, cm.getMsgId());
send(response, true);
break;
}
}
}