using System; using System.Collections.Generic; using Abp.Json; using Abp.Timing; namespace Abp.RealTime { /// /// Implements . /// [Serializable] public class OnlineClient : IOnlineClient { /// /// Unique connection Id for this client. /// public string ConnectionId { get; set; } /// /// IP address of this client. /// public string IpAddress { get; set; } /// /// Tenant Id. /// public int? TenantId { get; set; } /// /// User Id. /// public long? UserId { get; set; } /// /// Connection establishment time for this client. /// public DateTime ConnectTime { get; set; } /// /// Shortcut to set/get . /// public object this[string key] { get { return Properties[key]; } set { Properties[key] = value; } } /// /// Can be used to add custom properties for this client. /// public Dictionary Properties { get { return _properties; } set { if (value == null) { throw new ArgumentNullException(nameof(value)); } _properties = value; } } private Dictionary _properties; /// /// Initializes a new instance of the class. /// public OnlineClient() { ConnectTime = Clock.Now; } /// /// Initializes a new instance of the class. /// /// The connection identifier. /// The ip address. /// The tenant identifier. /// The user identifier. public OnlineClient(string connectionId, string ipAddress, int? tenantId, long? userId) : this() { ConnectionId = connectionId; IpAddress = ipAddress; TenantId = tenantId; UserId = userId; Properties = new Dictionary(); } public override string ToString() { return this.ToJsonString(); } } }