Files
caliverse_server/GameServer/Ticker/ChannelUpdateTicker.cs
2025-05-01 07:20:41 +09:00

65 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using ServerCore; using ServerBase;
using ServerCommon;
namespace GameServer
{
public class ChannelUpdateTicker : EntityTicker
{
public ChannelUpdateTicker(double onTickIntervalMilliseconds, CancellationTokenSource? cts)
: base(EntityType.ChannelUpdateTicker, onTickIntervalMilliseconds, cts)
{
}
public override async Task onTaskTick()
{
Stopwatch? stopwatch = null;
var event_tid = string.Empty;
var server_logic = GameServerApp.getServerLogic();
NullReferenceCheckHelper.throwIfNull(server_logic, () => $"server_logic is null !!!");
var server_config = server_logic.getServerConfig();
NullReferenceCheckHelper.throwIfNull(server_config, () => $"server_config is null !!!");
if(true == server_config.PerformanceCheckEnable)
{
event_tid = System.Guid.NewGuid().ToString("N");
stopwatch = Stopwatch.StartNew();
}
await GameServerApp.getServerLogic().getChannelManager().updateChannels();
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()}";
}
}
}