using System; using System.Collections.Generic; using System.Linq; namespace ln.http.resources.session { public class Session { public Guid SessionID { get; private set; } public long SessionAge => DateTimeOffset.Now.ToUnixTimeSeconds() - LastTouch; public long LastTouch { get; private set; } public HttpUser CurrentUser { get; set; } private readonly Dictionary elements = new Dictionary(); public Session() { SessionID = Guid.NewGuid(); CurrentUser = new HttpUser(); } public object this[string name] { get => this.elements[name]; set => this.elements[name] = value; } public String[] ElementNames => this.elements.Keys.ToArray(); public void Touch() { LastTouch = DateTimeOffset.Now.ToUnixTimeSeconds(); } public virtual void Authenticate(HttpRequest httpRequest) { } } }