2024-07-29 09:02:24 +00:00
|
|
|
|
using OverwatchTranscript;
|
|
|
|
|
|
|
|
|
|
namespace CodexPlugin.OverwatchSupport
|
2024-07-25 13:12:25 +00:00
|
|
|
|
{
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class OverwatchCodexHeader
|
|
|
|
|
{
|
2024-08-13 12:21:15 +00:00
|
|
|
|
public CodexNodeIdentity[] Nodes { get; set; } = Array.Empty<CodexNodeIdentity>();
|
2024-07-25 13:12:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class OverwatchCodexEvent
|
|
|
|
|
{
|
2024-08-13 12:21:15 +00:00
|
|
|
|
public int NodeIdentity { get; set; } = -1;
|
2024-07-25 14:00:51 +00:00
|
|
|
|
public ScenarioFinishedEvent? ScenarioFinished { get; set; }
|
2024-07-29 08:16:37 +00:00
|
|
|
|
public NodeStartingEvent? NodeStarting { get; set; }
|
2024-07-25 13:12:25 +00:00
|
|
|
|
public NodeStartedEvent? NodeStarted { get; set; }
|
2024-08-01 07:09:30 +00:00
|
|
|
|
public NodeStoppingEvent? NodeStopping { get; set; }
|
2024-07-29 08:16:37 +00:00
|
|
|
|
public BootstrapConfigEvent? BootstrapConfig { get; set; }
|
2024-08-01 07:09:30 +00:00
|
|
|
|
public FileUploadingEvent? FileUploading { get; set; }
|
2024-07-25 13:12:25 +00:00
|
|
|
|
public FileUploadedEvent? FileUploaded { get; set; }
|
2024-08-01 07:09:30 +00:00
|
|
|
|
public FileDownloadingEvent? FileDownloading { get; set; }
|
2024-07-25 13:12:25 +00:00
|
|
|
|
public FileDownloadedEvent? FileDownloaded { get; set; }
|
|
|
|
|
public BlockReceivedEvent? BlockReceived { get; set; }
|
2024-08-01 07:09:30 +00:00
|
|
|
|
public PeerDialSuccessfulEvent? DialSuccessful { get; set; }
|
|
|
|
|
public PeerDroppedEvent? PeerDropped { get; set; }
|
2024-07-29 09:02:24 +00:00
|
|
|
|
|
|
|
|
|
public void Write(DateTime utc, ITranscriptWriter writer)
|
|
|
|
|
{
|
2024-08-13 12:21:15 +00:00
|
|
|
|
if (NodeIdentity == -1 && ScenarioFinished == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("NodeIdentity not set, and event is not ScenarioFinished.");
|
|
|
|
|
}
|
2024-07-29 09:02:24 +00:00
|
|
|
|
if (AllNull()) throw new Exception("No event data was set");
|
|
|
|
|
|
|
|
|
|
writer.Add(utc, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool AllNull()
|
|
|
|
|
{
|
|
|
|
|
var props = GetType()
|
|
|
|
|
.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
|
|
|
|
|
.Where(p => p.PropertyType != typeof(string)).ToArray();
|
|
|
|
|
|
|
|
|
|
return props.All(p => p.GetValue(this) == null);
|
|
|
|
|
}
|
2024-07-25 13:12:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-13 11:48:54 +00:00
|
|
|
|
[Serializable]
|
|
|
|
|
public class CodexNodeIdentity
|
|
|
|
|
{
|
2024-08-13 12:21:15 +00:00
|
|
|
|
public string Name { get; set; } = string.Empty;
|
2024-08-13 11:48:54 +00:00
|
|
|
|
public string PeerId { get; set; } = string.Empty;
|
|
|
|
|
public string NodeId { get; set; } = string.Empty;
|
2024-08-14 13:10:33 +00:00
|
|
|
|
public float KademliaNormalizedPosition { get; set; } = 0.0f;
|
2024-08-13 11:48:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-25 13:12:25 +00:00
|
|
|
|
#region Scenario Generated Events
|
|
|
|
|
|
2024-07-25 14:00:51 +00:00
|
|
|
|
[Serializable]
|
|
|
|
|
public class ScenarioFinishedEvent
|
|
|
|
|
{
|
|
|
|
|
public bool Success { get; set; }
|
|
|
|
|
public string Result { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-25 13:12:25 +00:00
|
|
|
|
[Serializable]
|
2024-07-29 08:16:37 +00:00
|
|
|
|
public class NodeStartingEvent
|
2024-07-25 13:12:25 +00:00
|
|
|
|
{
|
|
|
|
|
public string Image { get; set; } = string.Empty;
|
2024-07-29 08:16:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class NodeStartedEvent
|
|
|
|
|
{
|
2024-07-25 13:12:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
2024-08-01 07:09:30 +00:00
|
|
|
|
public class NodeStoppingEvent
|
2024-07-25 13:12:25 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 08:16:37 +00:00
|
|
|
|
[Serializable]
|
|
|
|
|
public class BootstrapConfigEvent
|
|
|
|
|
{
|
|
|
|
|
public string BootstrapPeerId { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 07:09:30 +00:00
|
|
|
|
[Serializable]
|
|
|
|
|
public class FileUploadingEvent
|
|
|
|
|
{
|
|
|
|
|
public string UniqueId { get; set;} = string.Empty;
|
|
|
|
|
public long ByteSize { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class FileDownloadingEvent
|
|
|
|
|
{
|
|
|
|
|
public string Cid { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-25 13:12:25 +00:00
|
|
|
|
[Serializable]
|
|
|
|
|
public class FileUploadedEvent
|
|
|
|
|
{
|
2024-08-01 07:09:30 +00:00
|
|
|
|
public string UniqueId { get; set; } = string.Empty;
|
|
|
|
|
public long ByteSize { get; set; }
|
2024-07-25 13:12:25 +00:00
|
|
|
|
public string Cid { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class FileDownloadedEvent
|
|
|
|
|
{
|
|
|
|
|
public string Cid { get; set; } = string.Empty;
|
2024-08-01 07:09:30 +00:00
|
|
|
|
public long ByteSize { get; set; }
|
2024-07-25 13:12:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Codex Generated Events
|
|
|
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class BlockReceivedEvent
|
|
|
|
|
{
|
|
|
|
|
public string BlockAddress { get; set; } = string.Empty;
|
2024-07-26 08:11:29 +00:00
|
|
|
|
public string SenderPeerId { get; set; } = string.Empty;
|
2024-07-25 13:12:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 06:29:12 +00:00
|
|
|
|
[Serializable]
|
2024-08-01 07:09:30 +00:00
|
|
|
|
public class PeerDialSuccessfulEvent
|
2024-08-01 06:29:12 +00:00
|
|
|
|
{
|
|
|
|
|
public string TargetPeerId { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 07:09:30 +00:00
|
|
|
|
[Serializable]
|
|
|
|
|
public class PeerDroppedEvent
|
|
|
|
|
{
|
|
|
|
|
public string DroppedPeerId { get; set; } = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-25 13:12:25 +00:00
|
|
|
|
#endregion
|
|
|
|
|
}
|