초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,144 @@
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using ServerCore;
using ServerBase;
using ServerCommon;
using ServerCommon.BusinessLogDomain;
using MetaAssets;
namespace GameServer;
public class GlobalPartyDetailServerAction : EntityActionBase
{
private readonly PartyServerCacheRequest m_party_server_cache_request;
public GlobalPartyDetailServerAction(GlobalPartyDetail owner) : base(owner)
{
m_party_server_cache_request =
new PartyServerCacheRequest(owner.PartyGuid, GameServerApp.getServerLogic().getRedisConnector());
}
public override async Task<Result> onInit()
{
await Task.CompletedTask;
var result = new Result();
return result;
}
public override void onClear()
{
return;
}
public async Task<Result> keep()
{
return await m_party_server_cache_request.keepPartyServerCache();
}
public async Task<Result> loadPartyServer()
{
var party_server_attribute = getOwner().getEntityAttribute<PartyServerAttribute>();
NullReferenceCheckHelper.throwIfNull(party_server_attribute, () => $"PartyServerAttribute is null !! - {getOwner().toBasicString()}");
var result = await m_party_server_cache_request.fetchPartyServerCache();
if (result.isFail()) return result;
result = await ServerBase.DataCopyHelper.copyEntityAttributeFromCaches(party_server_attribute, new List<CacheBase> { m_party_server_cache_request.getPartyServerCache()! });
if (result.isFail())
{
Log.getLogger().error(result.toBasicString());
}
return result;
}
public IEnumerable<string> getServers()
{
var party_server_attribute = getOwner().getEntityAttribute<PartyServerAttribute>();
NullReferenceCheckHelper.throwIfNull(party_server_attribute, () => $"PartyServerAttribute is null !! - {getOwner().toBasicString()}");
return party_server_attribute.getPartyServers().ToList();
}
public async Task<Result> addPartyServer(string addServerName)
{
var party_server_attribute = getOwner().getEntityAttribute<PartyServerAttribute>();
NullReferenceCheckHelper.throwIfNull(party_server_attribute, () => $"PartyServerAttribute is null !! - {getOwner().toBasicString()}");
var result = await m_party_server_cache_request.addPartyServerCache(addServerName);
if (result.isFail()) return result;
party_server_attribute.addPartyServer(addServerName);
return result;
}
public async Task<Result> deletePartyServer(string delete_server_name)
{
// 1. cache 제거
var result = await m_party_server_cache_request.deletePartyServerCache(delete_server_name);
if (result.isFail()) return result;
// 2. attribute 수정
var attribute = getOwner().getEntityAttribute<PartyServerAttribute>();
NullReferenceCheckHelper.throwIfNull(attribute, () => $"PartyServerAttribute is null !! - {getOwner().toBasicString()}");
attribute.deleteServer(delete_server_name);
return result;
}
public async Task<Result> deleteAllPartyServers()
{
// 1. cache 제거
var result = await m_party_server_cache_request.deleteAllPartyServerCache();
if (result.isFail())
{
Log.getLogger().error(result.toBasicString());
}
// 2. attribute 수정
var party_server_attribute = getOwner().getEntityAttribute<PartyServerAttribute>();
NullReferenceCheckHelper.throwIfNull(party_server_attribute, () => $"PartyServerAttribute is null !! - {getOwner().toBasicString()}");
party_server_attribute.onClear();
return result;
}
public async Task<Result> notifyChangePartyServerToServers(BoolType isAddition, string srcServerName)
{
var party = getOwner() as GlobalPartyDetail;
NullReferenceCheckHelper.throwIfNull(party, () => $"party deltail is null !!!");
var party_server_attribute = getOwner().getEntityAttribute<PartyServerAttribute>();
NullReferenceCheckHelper.throwIfNull(party_server_attribute, () => $"PartyServerAttribute is null !! - {party.toBasicString()}");
var rabbit_mq = GameServerApp.getServerLogic().getRabbitMqConnector() as RabbitMqConnector;
NullReferenceCheckHelper.throwIfNull(rabbit_mq, () => $"rabbit mq is null !!! - {getOwner().toBasicString()}");
var message = new ServerMessage
{
ChangePartyServerNameNoti = new()
{
PartyGuid = party.PartyGuid,
IsAddition = isAddition,
ServerName = srcServerName
}
};
foreach (var dest_server in party_server_attribute.getPartyServers())
{
if (srcServerName == dest_server) continue;
rabbit_mq.SendMessage(dest_server, message);
}
return await Task.FromResult(new Result());
}
}