ln.http/session/Session.cs

44 lines
1.0 KiB
C#
Raw Normal View History

2019-02-26 22:00:37 +01:00
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; }
2019-03-13 08:24:24 +01:00
public HttpUser CurrentUser { get; set; }
2019-02-26 22:00:37 +01:00
private readonly Dictionary<string, object> elements = new Dictionary<string, object>();
public Session()
{
SessionID = Guid.NewGuid();
2019-03-13 08:24:24 +01:00
CurrentUser = new HttpUser();
2019-02-26 22:00:37 +01:00
}
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();
}
2019-03-13 08:24:24 +01:00
public virtual void Authenticate(HttpRequest httpRequest)
{
}
2019-02-26 22:00:37 +01:00
}
}