초기커밋
This commit is contained in:
@@ -0,0 +1,215 @@
|
||||
using Amazon.Runtime.Internal.Endpoints.StandardLibrary;
|
||||
using GameServer.PacketHandler;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
public class CharacterProfileAction : EntityActionBase
|
||||
{
|
||||
public CharacterProfileAction(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public async Task<Result> saveCharacterProfile(string sns_link, string message)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var fn_save_character_profile = async delegate ()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var invokers = new List<ILogInvoker>();
|
||||
|
||||
var character_profile_attribute = player.getEntityAttribute<CharacterProfileAttribute>();
|
||||
if (character_profile_attribute == null)
|
||||
{
|
||||
err_msg = $"Failed to get character profile attribute : {nameof(CharacterProfileAttribute)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
SaveCharacterProfilePacketHandler.send_S2C_ACK_SAVE_CHARACTER_PROFILE(player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
character_profile_attribute.SNSLick = sns_link;
|
||||
character_profile_attribute.Message = message;
|
||||
|
||||
character_profile_attribute.modifiedEntityAttribute();
|
||||
|
||||
var task_log_data = CharacterProfileBusinessLogHelper.toLogInfo(character_profile_attribute);
|
||||
invokers.Add(new CharacterProfileBusinessLog(task_log_data));
|
||||
|
||||
var batch = new QueryBatchEx<QueryRunnerWithDocument>(player, LogActionType.UpdateCharacterProfile
|
||||
, server_logic.getDynamoDbClient());
|
||||
{
|
||||
batch.addQuery(new DBQWriteToAttributeAllWithTransactionRunner());
|
||||
}
|
||||
|
||||
batch.appendBusinessLogs(invokers);
|
||||
|
||||
result = await QueryHelper.sendQueryAndBusinessLog(batch);
|
||||
if (result.isFail())
|
||||
{
|
||||
SaveCharacterProfilePacketHandler.send_S2C_ACK_SAVE_CHARACTER_PROFILE(player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
SaveCharacterProfilePacketHandler.send_S2C_ACK_SAVE_CHARACTER_PROFILE(player, result);
|
||||
return result;
|
||||
};
|
||||
|
||||
result = await player.runTransactionRunnerSafely(TransactionIdType.PrivateContents, "SaveCharacterProfile", fn_save_character_profile);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to runTransactionRunnerSafely()!!! : {result.toBasicString()} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<Result> getTargetCharacterProfile(string target_nickname)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var player_manager = server_logic.getPlayerManager();
|
||||
player_manager.tryGetUserBySubKey(target_nickname, out var target_player);
|
||||
|
||||
GetCharProfileRes? res = null;
|
||||
if (target_player == null)
|
||||
{
|
||||
(result, res) = await getOtherServerCharacterProfile(target_nickname);
|
||||
if (result.isFail())
|
||||
{
|
||||
GetCharacterProfilePacketHandler.send_S2C_ACK_GET_CHARACTER_PROFILE(player, result, null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(result, res) = getSameServerCharacterProfile(target_player);
|
||||
if (result.isFail())
|
||||
{
|
||||
GetCharacterProfilePacketHandler.send_S2C_ACK_GET_CHARACTER_PROFILE(player, result, null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
GetCharacterProfilePacketHandler.send_S2C_ACK_GET_CHARACTER_PROFILE(player, result, res);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private async Task<(Result, GetCharProfileRes?)> getOtherServerCharacterProfile(string target_nickname)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var player = getOwner() as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var dynamo_db_client = server_logic.getDynamoDbClient();
|
||||
|
||||
(result, var nickname_attrib) = await NicknameHelper.findNickname(target_nickname);
|
||||
if (result.isFail()) return (result, null);
|
||||
NullReferenceCheckHelper.throwIfNull(nickname_attrib, () => $"nickname_attrib is null !!!");
|
||||
|
||||
(result, var found_account_attrib) = await dynamo_db_client.simpleQueryDocTypeToAttrib<AccountBaseDoc, AccountBaseAttrib>(nickname_attrib.AccountId);
|
||||
if (result.isFail()) return (result, null);
|
||||
NullReferenceCheckHelper.throwIfNull(found_account_attrib, () => $"found_account_attrib is null !!!");
|
||||
|
||||
(result, var found_character_profile_attrib) = await dynamo_db_client.simpleQueryDocTypeToAttrib<CharacterProfileDoc, CharacterProfileAttrib>(nickname_attrib.UserGuid);
|
||||
if (result.isFail()) return (result, null);
|
||||
NullReferenceCheckHelper.throwIfNull(found_character_profile_attrib, () => $"found_character_profile_attrib is null !!!");
|
||||
|
||||
var res = new GetCharProfileRes();
|
||||
res.PublicGuid = ServerCore.EncryptionHelper.encryptTextByDES(found_account_attrib.UserGuid, EncryptData.DESEncryptKey, EncryptData.DESEncryptIv);
|
||||
res.NickName = target_nickname;
|
||||
res.SNSLink = found_character_profile_attrib.SNSLick;
|
||||
res.Message = found_character_profile_attrib.Message;
|
||||
res.Language = (int)found_account_attrib.LanguageType;
|
||||
|
||||
return (result, res);
|
||||
}
|
||||
|
||||
private (Result, GetCharProfileRes?) getSameServerCharacterProfile(Player target_player)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var character_profile_attribute = target_player.getEntityAttribute<CharacterProfileAttribute>();
|
||||
if (character_profile_attribute == null)
|
||||
{
|
||||
err_msg = $"Failed to get character profile attribute : {nameof(CharacterProfileAttribute)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
var account_attribute = target_player.getEntityAttribute<AccountAttribute>();
|
||||
if (account_attribute == null)
|
||||
{
|
||||
err_msg = $"Failed to get account attribute : {nameof(AccountAttribute)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
var ability_action = target_player.getEntityAction<AbilityAction>();
|
||||
if (ability_action == null)
|
||||
{
|
||||
err_msg = $"Failed to get ability action : {nameof(AbilityAction)}";
|
||||
result.setFail(ServerErrorCode.EntityActionNotFound, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
var target_abilities = ability_action.getAbilities();
|
||||
|
||||
var res = new GetCharProfileRes();
|
||||
res.PublicGuid = EncryptionHelper.encryptTextByDES(account_attribute.UserGuid, EncryptData.DESEncryptKey, EncryptData.DESEncryptIv);
|
||||
res.NickName = target_player.getUserNickname();
|
||||
res.SNSLink = character_profile_attribute.SNSLick;
|
||||
res.Message = character_profile_attribute.Message;
|
||||
res.Language = (int)account_attribute.LanguageType;
|
||||
|
||||
foreach(var ability in target_abilities)
|
||||
{
|
||||
res.Attributeinfo.Add(new AttributeInfo() { Attributeid = (int)ability.Key, Value = ability.Value });
|
||||
}
|
||||
|
||||
return (result, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
public class CharacterProfileBusinessLog : ILogInvokerEx
|
||||
{
|
||||
private CharacterProfileLogData m_data_to_log;
|
||||
public CharacterProfileBusinessLog(CharacterProfileLogData log_data_param)
|
||||
: base(LogDomainType.Craft)
|
||||
{
|
||||
m_data_to_log = log_data_param;
|
||||
}
|
||||
|
||||
public override bool hasLog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void fillup(ref BusinessLog.LogBody body)
|
||||
{
|
||||
body.append(new CharacterProfileLogData(this, m_data_to_log));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using ServerCommon;
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
static public class CharacterProfileBusinessLogHelper
|
||||
{
|
||||
static public CharacterProfileLogData toLogInfo(CharacterProfileAttribute attribute)
|
||||
{
|
||||
var logData = new CharacterProfileLogData();
|
||||
logData.setInfo(attribute);
|
||||
return logData;
|
||||
}
|
||||
|
||||
static public void setInfo(this CharacterProfileLogData logData, CharacterProfileAttribute attribute)
|
||||
{
|
||||
logData.SNSLick = attribute.SNSLick;
|
||||
logData.Message = attribute.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using static ClientToGameReq.Types;
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.GetCharProfileReq), typeof(GetCharacterProfilePacketHandler), typeof(GameLoginListener))]
|
||||
public class GetCharacterProfilePacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_GET_CHARACTER_PROFILE(Player player, Result result, GetCharProfileRes? res = null)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
if(res != null)
|
||||
{
|
||||
ack_packet.Response.GetCharProfileRes = res;
|
||||
}
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, ack_packet))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var entity_player = entityWithSession as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(entity_player, () => "player is null !!!");
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var character_profile_action = entity_player.getEntityAction<CharacterProfileAction>();
|
||||
if (character_profile_action == null)
|
||||
{
|
||||
err_msg = $"Failed to get character profile action : {nameof(CharacterProfileAction)}";
|
||||
result.setFail(ServerErrorCode.EntityActionNotFound, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
send_S2C_ACK_GET_CHARACTER_PROFILE(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.GetCharProfileReq)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_GET_CHARACTER_PROFILE(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.GetCharProfileReq;
|
||||
|
||||
result = await character_profile_action.getTargetCharacterProfile(request.NickName);
|
||||
if(result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to getTargetCharacterProfile() !!! : {result.toBasicString()} - {entity_player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task onProcessPacketException(ISession entityWithSession, IMessage recvMessage
|
||||
, Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var player = entityWithSession as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!! - {entityWithSession.toBasicString()}");
|
||||
|
||||
send_S2C_ACK_GET_CHARACTER_PROFILE(player, errorResult);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using Google.Protobuf;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon;
|
||||
|
||||
|
||||
using static ClientToGameReq.Types;
|
||||
using static ClientToGameRes.Types;
|
||||
|
||||
|
||||
|
||||
namespace GameServer.PacketHandler;
|
||||
|
||||
[PacketHandler(typeof(ClientToGameReq), typeof(ClientToGameReq.Types.SaveCharProfileReq), typeof(SaveCharacterProfilePacketHandler), typeof(GameLoginListener))]
|
||||
public class SaveCharacterProfilePacketHandler : PacketRecvHandler
|
||||
{
|
||||
public static bool send_S2C_ACK_SAVE_CHARACTER_PROFILE(Player player, Result result)
|
||||
{
|
||||
var ack_packet = new ClientToGame();
|
||||
ack_packet.Response = new ClientToGameRes();
|
||||
|
||||
ack_packet.Response.ErrorCode = result.ErrorCode;
|
||||
ack_packet.Response.SaveCharProfileRes = new();
|
||||
|
||||
if (false == GameServerApp.getServerLogic().onSendPacket(player, ack_packet))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override async Task<Result> onProcessPacket(ISession entityWithSession, IMessage recvMessage)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var entity_player = entityWithSession as Player;
|
||||
ArgumentNullException.ThrowIfNull(entity_player);
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var character_profile_action = entity_player.getEntityAction<CharacterProfileAction>();
|
||||
if (character_profile_action == null)
|
||||
{
|
||||
err_msg = $"Failed to get character profile action : {nameof(CharacterProfileAction)}";
|
||||
result.setFail(ServerErrorCode.EntityActionNotFound, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
send_S2C_ACK_SAVE_CHARACTER_PROFILE(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_msg = recvMessage as ClientToGame;
|
||||
if (game_msg == null)
|
||||
{
|
||||
err_msg = $"Failed to cast ClientToGame !!! : {nameof(ClientToGame.Request.SaveCharProfileReq)}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
send_S2C_ACK_SAVE_CHARACTER_PROFILE(entity_player, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
var request = game_msg.Request.SaveCharProfileReq;
|
||||
|
||||
result = await character_profile_action.saveCharacterProfile(request.SNSLink, request.Message);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to saveCharacterProfile() !!! : {result.toBasicString()} - {entity_player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
await QuestManager.It.QuestCheck(entity_player, new QuestAvatarProfile(EQuestEventTargetType.AVATARPROFILE, EQuestEventNameType.EDITED));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override async Task onProcessPacketException(ISession entityWithSession, IMessage recvMessage
|
||||
, Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var player = entityWithSession as Player;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!! - {entityWithSession.toBasicString()}");
|
||||
|
||||
send_S2C_ACK_SAVE_CHARACTER_PROFILE(player, errorResult);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user