diff options
Major Business Logic Implementation
* Added GameHub
* Added Back-End Game Loop and Game Mechanics
* Added End Game and Result message
1 files changed, 40 insertions, 0 deletions
| -rw-r--r-- | src/Web/PUSG.Web/Services/SessionService.cs | 40 |
diff --git a/src/Web/PUSG.Web/Services/SessionService.cs b/src/Web/PUSG.Web/Services/SessionService.cs new file mode 100644 index 0000000..0e8e61a --- /dev/null +++ b/src/Web/PUSG.Web/Services/SessionService.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Linq; + +namespace PUSG.Web.Static +{ + public class SessionService : ISessionService + { + private Dictionary<string, string> users; + + public SessionService() + { + this.users = new Dictionary<string, string>(); + this.LiveConnections = new List<string>(); + } + + public Dictionary<string, string> Users => this.users; + + public List<string> LiveConnections { get; } + + public void AddUser(string connectionId, string username) + { + this.users[connectionId] = username; + } + + public KeyValuePair<string, string> 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); + } + } +} |