using System;

namespace NoticeServer
{
    /// <summary>
    /// 채팅 메시지 타입
    /// </summary>
    public enum MessageType
    {
        /// <summary>클라이언트 연결</summary>
        Connect,
        /// <summary>클라이언트 연결 해제</summary>
        Disconnect,
        /// <summary>일반 채팅 메시지</summary>
        Chat,
        /// <summary>서버 공지</summary>
        Notice,
        /// <summary>귓속말</summary>
        Whisper,
        /// <summary>사용자 목록 요청</summary>
        UserListRequest,
        /// <summary>사용자 목록 응답</summary>
        UserListResponse,
        /// <summary>핑 (연결 유지)</summary>
        Ping,
        /// <summary>퐁 (핑 응답)</summary>
        Pong
    }

    /// <summary>
    /// 채팅 메시지 프로토콜
    /// </summary>
    [Serializable]
    public class ChatMessage
    {
        /// <summary>메시지 타입</summary>
        public MessageType Type { get; set; }

        /// <summary>발신자 닉네임</summary>
        public string NickName { get; set; }

        /// <summary>발신자 사원번호 (Employee ID)</summary>
        public string EmployeeId { get; set; }

        /// <summary>발신자 IP</summary>
        public string IpAddress { get; set; }

        /// <summary>발신자 호스트명</summary>
        public string HostName { get; set; }

        /// <summary>메시지 내용</summary>
        public string Content { get; set; }

        /// <summary>수신자 사원번호 (1:1 채팅용)</summary>
        public string TargetEmployeeId { get; set; }

        /// <summary>수신자 닉네임 (귓속말용, null이면 전체)</summary>
        public string TargetNickName { get; set; }

        /// <summary>전송 시간</summary>
        public DateTime Timestamp { get; set; }

        /// <summary>사용자 그룹</summary>
        public string UserGroup { get; set; }

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

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