cs-codex-dist-tests/Tools/TranscriptAnalysis/Receivers/BaseReceiver.cs

43 lines
1.1 KiB
C#
Raw Normal View History

2024-08-14 12:13:00 +00:00
using CodexPlugin.OverwatchSupport;
using Logging;
2024-08-07 09:18:40 +00:00
using OverwatchTranscript;
namespace TranscriptAnalysis.Receivers
{
public abstract class BaseReceiver<T> : IEventReceiver<T>
{
protected ILog log { get; private set; } = new NullLog();
2024-08-14 12:13:00 +00:00
protected OverwatchCodexHeader Header { get; private set; } = null!;
2024-08-07 09:18:40 +00:00
public abstract string Name { get; }
public abstract void Receive(ActivateEvent<T> @event);
public abstract void Finish();
2024-08-14 12:13:00 +00:00
public void Init(ILog log, OverwatchCodexHeader header)
2024-08-07 09:18:40 +00:00
{
this.log = new LogPrefixer(log, $"({Name}) ");
2024-08-14 12:13:00 +00:00
Header = header;
}
protected string GetPeerId(int nodeIndex)
{
return GetIdentity(nodeIndex).PeerId;
}
protected string GetName(int nodeIndex)
{
return GetIdentity(nodeIndex).Name;
}
protected CodexNodeIdentity GetIdentity(int nodeIndex)
{
return Header.Nodes[nodeIndex];
2024-08-07 09:18:40 +00:00
}
protected void Log(string msg)
{
log.Log(msg);
}
}
}