using System.Text.Json.Serialization; namespace Titano.Protocol; /// /// Messages pushed on WS /api/v1/events. Each frame is one JSON object with a type discriminator: /// jobProgress, jobState, sequenceChanged, cardEvent, nodeState. /// [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] [JsonDerivedType(typeof(JobProgressEvent), "jobProgress")] [JsonDerivedType(typeof(JobStateEvent), "jobState")] [JsonDerivedType(typeof(SequenceChangedEvent), "sequenceChanged")] [JsonDerivedType(typeof(NodeStateEvent), "nodeState")] public abstract record ServerEvent; public sealed record JobProgressEvent(Guid JobId, long Done, long Total, double? ItemsPerSecond, double? EtaSeconds) : ServerEvent; public sealed record JobStateEvent(Guid JobId, string State, string? Error) : ServerEvent; public sealed record SequenceChangedEvent(Guid SequenceId, string Change, int FramesVersion, int SettingsVersion) : ServerEvent; public sealed record NodeStateEvent(Guid NodeId, string ClientName, string State) : ServerEvent;