using MessagePack;

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

[MessagePackObject]
public sealed class OpenSessionRequest
{
    [Key(0)] public string DriverInstanceId { get; set; } = string.Empty;

    /// <summary>JSON blob sourced from <c>DriverInstance.DriverConfig</c>.</summary>
    [Key(1)] public string DriverConfigJson { get; set; } = string.Empty;
}

[MessagePackObject]
public sealed class OpenSessionResponse
{
    [Key(0)] public bool Success { get; set; }
    [Key(1)] public string? Error { get; set; }
    [Key(2)] public long SessionId { get; set; }
}

[MessagePackObject]
public sealed class CloseSessionRequest
{
    [Key(0)] public long SessionId { get; set; }
}

[MessagePackObject]
public sealed class Heartbeat
{
    [Key(0)] public long SequenceNumber { get; set; }
    [Key(1)] public long UtcUnixMs { get; set; }
}

[MessagePackObject]
public sealed class HeartbeatAck
{
    [Key(0)] public long SequenceNumber { get; set; }
    [Key(1)] public long UtcUnixMs { get; set; }
}

[MessagePackObject]
public sealed class ErrorResponse
{
    [Key(0)] public string Code { get; set; } = string.Empty;
    [Key(1)] public string Message { get; set; } = string.Empty;
}
