using System.Threading.Channels;
using ZB.MOM.WW.MxGateway.Contracts.Proto;

namespace ZB.MOM.WW.MxGateway.Server.Dashboard.Hubs;

/// <summary>
/// A live in-process feed of one session's dashboard-mirrored MxEvents, handed
/// out by <see cref="IDashboardSessionEventSubscriber.Subscribe"/>. Server-side
/// Blazor components read it directly instead of looping back through
/// <see cref="EventsHub"/> over a loopback SignalR connection.
/// </summary>
/// <remarks>
/// Events are delivered exactly as a hub client would see them — the same
/// redacted clone the group send carries, so <c>MxGateway:Dashboard:ShowTagValues</c>
/// governs both paths identically. The feed is a bounded, lossy queue: a
/// consumer that falls behind loses the oldest queued events, matching the
/// best-effort contract the SignalR mirror already has. Disposing the
/// subscription deregisters it, which is what lets the broadcaster go back to
/// skipping all mirror work for a session nobody is watching — so callers must
/// dispose. Dispose is idempotent.
/// </remarks>
public interface IDashboardEventSubscription : IDisposable
{
    /// <summary>Gets the reader delivering this session's mirrored events.</summary>
    ChannelReader<MxEvent> Reader { get; }
}
