using System.Collections.Generic; using System.Linq; namespace PUSG.Web.Services { public class SessionService : ISessionService { private Dictionary users; public SessionService() { this.users = new Dictionary(); this.LiveConnections = new List(); } public Dictionary Users => this.users; public List LiveConnections { get; } public void AddUser(string connectionId, string username) { this.users[connectionId] = username; } public KeyValuePair GetUser(string connectionId) { return this.users.SingleOrDefault(user => user.Key == connectionId); } public bool IsLogged(string credential) { return this.users.ContainsKey(credential) || this.users.ContainsValue(credential); } public void RemoveUser(string connectionId) { this.users.Remove(connectionId); } } }