using System;

namespace Project
{
    /// <summary>
    /// Chat message type
    /// </summary>
    public enum MessageType
    {
        /// <summary>Client connect</summary>
        Connect = 0,
        /// <summary>Client disconnect</summary>
        Disconnect = 1,
        /// <summary>Normal chat message</summary>
        Chat = 2,
        /// <summary>Server notice</summary>
        Notice = 3,
        /// <summary>Whisper message</summary>
        Whisper = 4,
        /// <summary>User list request</summary>
        UserListRequest = 5,
        /// <summary>User list response</summary>
        UserListResponse = 6,
        /// <summary>Ping (keep alive)</summary>
        Ping = 7,
        /// <summary>Pong (ping response)</summary>
        Pong = 8
    }

    /// <summary>
    /// Chat message protocol
    /// </summary>
    [Serializable]
    public class ChatMessage
    {
        /// <summary>Message type</summary>
        public MessageType Type { get; set; }

        /// <summary>Sender nickname</summary>
        public string NickName { get; set; }

        /// <summary>Sender employee ID (사번)</summary>
        public string EmployeeId { get; set; }

        /// <summary>Sender IP</summary>
        public string IpAddress { get; set; }

        /// <summary>Sender hostname</summary>
        public string HostName { get; set; }

        /// <summary>Message content</summary>
        public string Content { get; set; }

        /// <summary>Target employee ID (for 1:1 chat)</summary>
        public string TargetEmployeeId { get; set; }

        /// <summary>Target nickname (for whisper, null for broadcast)</summary>
        public string TargetNickName { get; set; }

        /// <summary>Send time</summary>
        public DateTime Timestamp { get; set; }

        /// <summary>User group (for filtering)</summary>
        public string UserGroup { get; set; }

        public ChatMessage()
        {
            Timestamp = DateTime.Now;
        }

        public override string ToString()
        {
            return $"[{Timestamp:HH:mm:ss}] {NickName}: {Content}";
        }
    }
}
