Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Web / PUSG.Web / Static / SessionService.cs
diff options
context:
space:
mode:
Commit6fb05a2a6f94e008dc689291d0522f39f87a6622 (patch)
Author
 ivaylo.zhelev <ivaylo.zhelev@solarwinds.com>
2021-01-24 14:45:23 +0200
Committer
 ivaylo.zhelev <ivaylo.zhelev@solarwinds.com>
2021-01-24 14:45:23 +0200
Files845087b1419336f526b68678d92d090c1076a132 /src/Web/PUSG.Web/Static/SessionService.cs
pusg-api-6fb05a2a6f94e008dc689291d0522f39f87a6622.tar
pusg-api-6fb05a2a6f94e008dc689291d0522f39f87a6622.tar.gz
pusg-api-6fb05a2a6f94e008dc689291d0522f39f87a6622.zip
Parentd62fcf4e8af0705756bcf159588c0e5eeab1a56d (diff)
Initial Commit - Add all project files
1 files changed, 40 insertions, 0 deletions
-rw-r--r--src/Web/PUSG.Web/Static/SessionService.cs40
diff --git a/src/Web/PUSG.Web/Static/SessionService.cs b/src/Web/PUSG.Web/Static/SessionService.cs
new file mode 100644
index 0000000..0e8e61a
--- /dev/null
+++ b/src/Web/PUSG.Web/Static/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);
+ }
+ }
+}