using System;

namespace ZB.MOM.WW.LmxProxy.Host.Domain
{
    /// <summary>
    ///     Event arguments for SCADA client connection state changes.
    /// </summary>
    public class ConnectionStateChangedEventArgs : EventArgs
    {
        /// <summary>
        ///     Initializes a new instance of the <see cref="ConnectionStateChangedEventArgs" /> class.
        /// </summary>
        /// <param name="previousState">The previous connection state.</param>
        /// <param name="currentState">The current connection state.</param>
        /// <param name="message">Optional message providing additional information about the state change.</param>
        public ConnectionStateChangedEventArgs(ConnectionState previousState, ConnectionState currentState,
            string? message = null)
        {
            PreviousState = previousState;
            CurrentState = currentState;
            Timestamp = DateTime.UtcNow;
            Message = message;
        }

        /// <summary>
        ///     Gets the previous connection state.
        /// </summary>
        public ConnectionState PreviousState { get; }

        /// <summary>
        ///     Gets the current connection state.
        /// </summary>
        public ConnectionState CurrentState { get; }

        /// <summary>
        ///     Gets the timestamp when the state change occurred.
        /// </summary>
        public DateTime Timestamp { get; }

        /// <summary>
        ///     Gets additional information about the state change, such as error messages.
        /// </summary>
        public string? Message { get; }
    }
}
