mirror of
https://bitbucket.org/seefoe/src.git
synced 2026-07-30 00:15:46 -04:00
last of the central server ones
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include "sharedNetwork/Service.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
#include "sharedFoundation/CrcConstexpr.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection::CentralServerConnection(const std::string & a, const unsigned short p) :
|
||||
@@ -62,63 +64,73 @@ void CentralServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
GameNetworkMessage m(ri);
|
||||
|
||||
ri = message.begin();
|
||||
|
||||
const uint32 messageType = message.getType();
|
||||
|
||||
if(m.isType("EnumerateServers"))
|
||||
{
|
||||
static MessageDispatch::Transceiver<const EnumerateServers &> emitter;
|
||||
|
||||
EnumerateServers e(ri);
|
||||
emitter.emitMessage(e);
|
||||
}
|
||||
else if (m.isType("CustomerServiceServerChatServerServiceAddress"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned short> > msg(ri);
|
||||
|
||||
ChatServer::instance().connectToCustomerServiceServer(msg.getValue().first, msg.getValue().second);
|
||||
}
|
||||
else if(m.isType("RequestChatTransferAvatar"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received RequestChatTransferAvatar from CentralServer. Forwarding request to ChatAPI. %s", request.getValue().toString().c_str()));
|
||||
ChatServer::requestTransferAvatar(request.getValue());
|
||||
}
|
||||
else if (m.isType("RenameCharacterMessageEx"))
|
||||
{
|
||||
RenameCharacterMessageEx const msg(ri);
|
||||
|
||||
// if the player requested the rename, also rename the chat
|
||||
// avatar, so mail, friends list, and ignore list will migrate
|
||||
if ((msg.getRenameCharacterMessageSource() == RenameCharacterMessageEx::RCMS_player_request) && !msg.getLastNameChangeOnly() && !ConfigFile::getKeyBool("CharacterRename", "disableRenameChatAvatar", false))
|
||||
switch(messageType) {
|
||||
case constcrc("EnumerateServers") :
|
||||
{
|
||||
std::string const oldName(Unicode::toLower(Unicode::wideToNarrow(msg.getOldName())));
|
||||
std::string const oldNameNormalized(oldName, 0, oldName.find(' '));
|
||||
ChatAvatarId const oldAvatar("SWG", ConfigChatServer::getClusterName(), oldNameNormalized);
|
||||
static MessageDispatch::Transceiver<const EnumerateServers &> emitter;
|
||||
|
||||
std::string const newName(Unicode::toLower(Unicode::wideToNarrow(msg.getNewName())));
|
||||
std::string const newNameNormalized(newName, 0, newName.find(' '));
|
||||
ChatAvatarId const newAvatar("SWG", ConfigChatServer::getClusterName(), newNameNormalized);
|
||||
|
||||
IGNORE_RETURN(ChatServer::getChatInterface()->RequestTransferAvatar(msg.getStationId(), oldAvatar.getName(), oldAvatar.getAPIAddress(), msg.getStationId(), newAvatar.getName(), newAvatar.getAPIAddress(), true, nullptr));
|
||||
EnumerateServers e(ri);
|
||||
emitter.emitMessage(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (m.isType("ChatDestroyAvatar"))
|
||||
{
|
||||
GenericValueTypeMessage<std::string> const msg(ri);
|
||||
ChatServer::getChatInterface()->DestroyAvatar(msg.getValue());
|
||||
}
|
||||
else if(m.isType("AllCluserGlobalChannel"))
|
||||
{
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
case constcrc("CustomerServiceServerChatServerServiceAddress") :
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::string, unsigned short> > msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
ChatServer::instance().connectToCustomerServiceServer(msg.getValue().first, msg.getValue().second);
|
||||
break;
|
||||
}
|
||||
else if(m.isType("RequestChatTransferAvatar"))
|
||||
{
|
||||
GenericValueTypeMessage<TransferCharacterData> request(ri);
|
||||
LOG("CustomerService", ("CharacterTransfer: Received RequestChatTransferAvatar from CentralServer. Forwarding request to ChatAPI. %s", request.getValue().toString().c_str()));
|
||||
ChatServer::requestTransferAvatar(request.getValue());
|
||||
break;
|
||||
}
|
||||
case constcrc("RenameCharacterMessageEx") :
|
||||
{
|
||||
RenameCharacterMessageEx const msg(ri);
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: ChatServer got AllCluserGlobalChannel on CentralServerConnection chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0)));
|
||||
ChatServer::requestBroadcastChannelMessage(channelName, messageText, isRemove);
|
||||
// if the player requested the rename, also rename the chat
|
||||
// avatar, so mail, friends list, and ignore list will migrate
|
||||
if ((msg.getRenameCharacterMessageSource() == RenameCharacterMessageEx::RCMS_player_request) && !msg.getLastNameChangeOnly() && !ConfigFile::getKeyBool("CharacterRename", "disableRenameChatAvatar", false))
|
||||
{
|
||||
std::string const oldName(Unicode::toLower(Unicode::wideToNarrow(msg.getOldName())));
|
||||
std::string const oldNameNormalized(oldName, 0, oldName.find(' '));
|
||||
ChatAvatarId const oldAvatar("SWG", ConfigChatServer::getClusterName(), oldNameNormalized);
|
||||
|
||||
std::string const newName(Unicode::toLower(Unicode::wideToNarrow(msg.getNewName())));
|
||||
std::string const newNameNormalized(newName, 0, newName.find(' '));
|
||||
ChatAvatarId const newAvatar("SWG", ConfigChatServer::getClusterName(), newNameNormalized);
|
||||
|
||||
IGNORE_RETURN(ChatServer::getChatInterface()->RequestTransferAvatar(msg.getStationId(), oldAvatar.getName(), oldAvatar.getAPIAddress(), msg.getStationId(), newAvatar.getName(), newAvatar.getAPIAddress(), true, nullptr));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case constcrc("ChatDestroyAvatar") :
|
||||
{
|
||||
GenericValueTypeMessage<std::string> const msg(ri);
|
||||
ChatServer::getChatInterface()->DestroyAvatar(msg.getValue());
|
||||
break;
|
||||
}
|
||||
case constcrc("AllCluserGlobalChannel") :
|
||||
{
|
||||
typedef std::pair<std::pair<std::string,std::string>, bool> PayloadType;
|
||||
GenericValueTypeMessage<PayloadType> msg(ri);
|
||||
|
||||
PayloadType const & payload = msg.getValue();
|
||||
std::string const & channelName = payload.first.first;
|
||||
std::string const & messageText = payload.first.second;
|
||||
bool const & isRemove = payload.second;
|
||||
|
||||
LOG("CustomerService", ("BroadcastVoiceChannel: ChatServer got AllCluserGlobalChannel on CentralServerConnection chan(%s) text(%s) remove(%d)",
|
||||
channelName.c_str(), messageText.c_str(), (isRemove?1:0)));
|
||||
ChatServer::requestBroadcastChannelMessage(channelName, messageText, isRemove);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user