34 lines
855 B
C#
34 lines
855 B
C#
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; }
|
|
|
|
private readonly Dictionary<string, object> elements = new Dictionary<string, object>();
|
|
|
|
public Session()
|
|
{
|
|
SessionID = Guid.NewGuid();
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|