diff --git a/engine/server/application/ConnectionServer/src/shared/CentralConnection.cpp b/engine/server/application/ConnectionServer/src/shared/CentralConnection.cpp index 07c3b71f..5ca0cca1 100755 --- a/engine/server/application/ConnectionServer/src/shared/CentralConnection.cpp +++ b/engine/server/application/ConnectionServer/src/shared/CentralConnection.cpp @@ -1,8 +1,3 @@ -// CentralConnection.cpp -// copyright 2001 Verant Interactive - -//----------------------------------------------------------------------- - #include "FirstConnectionServer.h" #include "CentralConnection.h" @@ -19,6 +14,8 @@ #include "sharedNetworkMessages/ErrorMessage.h" #include "sharedNetworkMessages/GenericValueTypeMessage.h" +#include "sharedFoundation/CrcConstexpr.hpp" + //----------------------------------------------------------------------- CentralConnection::CentralConnection(const std::string & address, const unsigned short port) : @@ -67,68 +64,79 @@ void CentralConnection::onReceive(const Archive::ByteStream & message) Archive::ReadIterator ri = message.begin(); const GameNetworkMessage msg(ri); ri = message.begin(); - - if(msg.isType("TransferLoginCharacterToSourceServer")) + + switch(msg.getType()) { - GenericValueTypeMessage login(ri); - // received a request to create a pseudoclient and connect it - // to a game server. - LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received TransferLoginCharacterToSourceServer request from CentralServer for %s\n", login.getValue().toString().c_str())); - IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(login.getValue().getSourceStationId(), message)); - } - else if(msg.isType("TransferLoginCharacterToDestinationServer")) - { - GenericValueTypeMessage login(ri); - LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received TransferLoginCharacterToDestinationServer request from CentralServer for %s", login.getValue().toString().c_str())); - IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(login.getValue().getDestinationStationId(), message)); - } - else if(msg.isType("CtsSrcCharWrongPlanet")) - { - GenericValueTypeMessage > const failureMsg(ri); - LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received CtsSrcCharWrongPlanet error from CentralServer for character (%s) stationId (%u) because character is not one of the 10 original ground planets", failureMsg.getValue().first.getValueString().c_str(), failureMsg.getValue().second)); - IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(failureMsg.getValue().second, message)); - } - else if(msg.isType("TransferKickConnectedClients")) - { - GenericValueTypeMessage kick(ri); - ClientConnection * clientConnection = ConnectionServer::getClientConnection(kick.getValue()); - if(clientConnection) - { - ConnectionServer::dropClient(clientConnection, "TransferServer requests client drop"); - } - } - else if(msg.isType("TransferClosePseudoClientConnection")) - { - GenericValueTypeMessage closeRequest(ri); - PseudoClientConnection * pseudoClient = PseudoClientConnection::getPseudoClientConnection(closeRequest.getValue()); - delete pseudoClient; - } - else if(msg.isType("LoginDeniedRecentCTS")) - { - GenericValueTypeMessage > loginDeniedRecentCTS(ri); - ClientConnection * clientConnection = ConnectionServer::getClientConnection(loginDeniedRecentCTS.getValue().second); - if (clientConnection) - { - LOG("CustomerService", ("Login:%s, character %s (%s) is a recent CTS that has not been persisted yet.", ClientConnection::describeAccount(clientConnection).c_str(), clientConnection->getCharacterName().c_str(), clientConnection->getCharacterId().getValueString().c_str())); - ErrorMessage err("Login Failed", "The selected character has just been recently transferred and has not been completely initialized. In most cases, it takes about 15 minutes (but in some cases can take up to 2 hours) to complete initialization. Please try again later."); - clientConnection->send(err, true); - } - } - else if(msg.isType("LoginDeniedPendingPlayerRenameRequest")) - { - GenericValueTypeMessage > loginDeniedPendingPlayerRenameRequest(ri); - ClientConnection * clientConnection = ConnectionServer::getClientConnection(loginDeniedPendingPlayerRenameRequest.getValue().second); - if (clientConnection) - { - LOG("CustomerService", ("Login:%s, character %s (%s) has a pending player requested character rename request.", ClientConnection::describeAccount(clientConnection).c_str(), clientConnection->getCharacterName().c_str(), clientConnection->getCharacterId().getValueString().c_str())); - ErrorMessage err("Login Failed", "The selected character currently has a pending character rename request. It can take up to 30 minutes for the rename request to complete."); - clientConnection->send(err, true); - } - } - else - { - ServerConnection::onReceive(message); + case constcrc("TransferLoginCharacterToSourceServer") : + { + GenericValueTypeMessage login(ri); + // received a request to create a pseudoclient and connect it + // to a game server. + LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received TransferLoginCharacterToSourceServer request from CentralServer for %s\n", login.getValue().toString().c_str())); + IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(login.getValue().getSourceStationId(), message)); + break; + } + case constcrc("TransferLoginCharacterToDestinationServer") : + { + GenericValueTypeMessage login(ri); + LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received TransferLoginCharacterToDestinationServer request from CentralServer for %s", login.getValue().toString().c_str())); + IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(login.getValue().getDestinationStationId(), message)); + break; + } + case constcrc("CtsSrcCharWrongPlanet") : + { + GenericValueTypeMessage > const failureMsg(ri); + LOG("CustomerService", ("CharacterTransfer: ***ConnectionServer: Received CtsSrcCharWrongPlanet error from CentralServer for character (%s) stationId (%u) because character is not one of the 10 original ground planets", failureMsg.getValue().first.getValueString().c_str(), failureMsg.getValue().second)); + IGNORE_RETURN(PseudoClientConnection::tryToDeliverMessageTo(failureMsg.getValue().second, message)); + break; + } + case constcrc("TransferKickConnectedClients") : + { + GenericValueTypeMessage kick(ri); + ClientConnection * clientConnection = ConnectionServer::getClientConnection(kick.getValue()); + if(clientConnection) + { + ConnectionServer::dropClient(clientConnection, "TransferServer requests client drop"); + } + break; + } + case constcrc("TransferClosePseudoClientConnection") : + { + GenericValueTypeMessage closeRequest(ri); + PseudoClientConnection * pseudoClient = PseudoClientConnection::getPseudoClientConnection(closeRequest.getValue()); + delete pseudoClient; + break; + } + case constcrc("LoginDeniedRecentCTS") : + { + GenericValueTypeMessage > loginDeniedRecentCTS(ri); + ClientConnection * clientConnection = ConnectionServer::getClientConnection(loginDeniedRecentCTS.getValue().second); + if (clientConnection) + { + LOG("CustomerService", ("Login:%s, character %s (%s) is a recent CTS that has not been persisted yet.", ClientConnection::describeAccount(clientConnection).c_str(), clientConnection->getCharacterName().c_str(), clientConnection->getCharacterId().getValueString().c_str())); + ErrorMessage err("Login Failed", "The selected character has just been recently transferred and has not been completely initialized. In most cases, it takes about 15 minutes (but in some cases can take up to 2 hours) to complete initialization. Please try again later."); + clientConnection->send(err, true); + } + break; + } + case constcrc("LoginDeniedPendingPlayerRenameRequest") : + { + GenericValueTypeMessage > loginDeniedPendingPlayerRenameRequest(ri); + ClientConnection * clientConnection = ConnectionServer::getClientConnection(loginDeniedPendingPlayerRenameRequest.getValue().second); + if (clientConnection) + { + LOG("CustomerService", ("Login:%s, character %s (%s) has a pending player requested character rename request.", ClientConnection::describeAccount(clientConnection).c_str(), clientConnection->getCharacterName().c_str(), clientConnection->getCharacterId().getValueString().c_str())); + ErrorMessage err("Login Failed", "The selected character currently has a pending character rename request. It can take up to 30 minutes for the rename request to complete."); + clientConnection->send(err, true); + } + break; + } + default: + ServerConnection::onReceive(message); + break; } } //----------------------------------------------------------------------- + +