using Fleck;
using MessagePack;
using TouchSocket.Core;
using System.Collections.Concurrent;
using StackExchange.Redis;

namespace CrazyStudio.Core.Common.Status.Eitities
{
    [MessagePackObject]
    public class OnlineUserInfo
    {
        [Key(0)]
        /// <summary>
        /// 链接ID,每个链接唯一，每个用户可能有多个
        /// </summary>
        public string ConnectionId { get; set; } = string.Empty;


        [Key(1)]
        /// <summary>
        /// 用户ID，每个用户唯一
        /// </summary>
        public string UserName { get; set; } = string.Empty;


        /// <summary>
        /// 用户房间ID
        /// </summary>
        [Key(2)]
        public string RoomId { get; set; } = string.Empty;


        /// <summary>
        /// 用户是否是主机
        /// </summary>
        [Key(3)]
        public bool IsHost { get; set; } = false;
        //[Key(3)]
        //public ConcurrentDictionary<string, string> AtServers { get; set; } = new ConcurrentDictionary<string, string>();


        //public ByteBlock ReceiveData = new ByteBlock(4096);

        [Key(4)]
        /// <summary>
        /// 用户头像Url
        /// </summary>
        public string AvatarUrl { get; set; } = string.Empty;

        [IgnoreMember]
        /// <summary>
        /// WebSocket对象
        /// </summary>
        public required IWebSocketConnection Socket { get; set; }


        [IgnoreMember]
        /// <summary>
        /// -1表示不需要心跳包检测
        /// </summary>
        public int HeartBeatDurationMs { get; set; } = -1;
    }
}
