80 lines
2.4 KiB
C#
80 lines
2.4 KiB
C#
using System.Diagnostics;
|
|
|
|
|
|
using Google.Protobuf;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
using ServerCommon;
|
|
using ServerCommon.BusinessLogDomain;
|
|
using MetaAssets;
|
|
|
|
|
|
namespace GameServer;
|
|
|
|
|
|
public class PartyCacheRefreshTicker : EntityTicker
|
|
{
|
|
public PartyCacheRefreshTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
|
|
: base(EntityType.PartyCacheRefreshTicker, onTickIntervalMilliseconds, cts)
|
|
{
|
|
}
|
|
|
|
public override async Task onTaskTick()
|
|
{
|
|
Stopwatch? stopwatch = null;
|
|
var event_tid = string.Empty;
|
|
|
|
var server_logic = GameServerApp.getServerLogic();
|
|
ArgumentNullException.ThrowIfNull(server_logic);
|
|
var server_config = server_logic.getServerConfig();
|
|
ArgumentNullException.ThrowIfNull(server_config);
|
|
|
|
foreach (var each in server_logic.getPlayerManager().getUsers())
|
|
{
|
|
var user = each.Value;
|
|
|
|
var user_create_or_load_action = user.getEntityAction<UserCreateOrLoadAction>();
|
|
ArgumentNullException.ThrowIfNull(user_create_or_load_action, $"user_create_or_load_action is null !!! - {user.toBasicString()}");
|
|
|
|
if (false == user_create_or_load_action.isCompletedLoadUser())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var party_action = user.getEntityAction<PersonalPartyAction>();
|
|
ArgumentNullException.ThrowIfNull(party_action);
|
|
|
|
if (party_action.isParty())
|
|
{
|
|
var result = await party_action.runPartyTick();
|
|
if(result.isFail())
|
|
{
|
|
var err_msg = $"Failed to runPartyTick() !!! : {result.toBasicString()} - {user.toBasicString()}";
|
|
Log.getLogger().error(err_msg);
|
|
}
|
|
}
|
|
|
|
await Task.Delay(10); // 레디스 IO 오버헤드 감경 !!!
|
|
}
|
|
|
|
if (null != stopwatch)
|
|
{
|
|
var elapsed_msec = stopwatch.ElapsedMilliseconds;
|
|
stopwatch.Stop();
|
|
Log.getLogger().debug($"{GetType()} Ticker Stopwatch Stop : ETID:{event_tid}, ElapsedMSec:{elapsed_msec}, TickIntervalMSec:{getOnTickIntervalMilliseconds()}");
|
|
}
|
|
}
|
|
|
|
public override string toBasicString()
|
|
{
|
|
return $"{this.getTypeName()}";
|
|
}
|
|
|
|
public override string toSummaryString()
|
|
{
|
|
return $"{this.getTypeName()}";
|
|
}
|
|
} |