using MessagePack;

namespace ZB.MOM.WW.OtOpcUa.Driver.FOCAS.Shared.Contracts;

/// <summary>Lightweight connectivity probe — maps to <c>cnc_rdcncstat</c> on the Host.</summary>
[MessagePackObject]
public sealed class ProbeRequest
{
    [Key(0)] public long SessionId { get; set; }
    [Key(1)] public int TimeoutMs { get; set; } = 2000;
}

[MessagePackObject]
public sealed class ProbeResponse
{
    [Key(0)] public bool Healthy { get; set; }
    [Key(1)] public string? Error { get; set; }
    [Key(2)] public long ObservedAtUtcUnixMs { get; set; }
}

/// <summary>Per-host runtime status — fan-out target when the Host observes the CNC going unreachable without the Proxy asking.</summary>
[MessagePackObject]
public sealed class RuntimeStatusChangeNotification
{
    [Key(0)] public long SessionId { get; set; }

    /// <summary>Running | Stopped | Unknown.</summary>
    [Key(1)] public string RuntimeStatus { get; set; } = string.Empty;

    [Key(2)] public long ObservedAtUtcUnixMs { get; set; }
}

[MessagePackObject]
public sealed class RecycleHostRequest
{
    /// <summary>Soft | Hard. Soft drains subscriptions first; Hard kills immediately.</summary>
    [Key(0)] public string Kind { get; set; } = "Soft";
    [Key(1)] public string Reason { get; set; } = string.Empty;
}

[MessagePackObject]
public sealed class RecycleStatusResponse
{
    [Key(0)] public bool Accepted { get; set; }
    [Key(1)] public int GraceSeconds { get; set; } = 15;
    [Key(2)] public string? Error { get; set; }
}
