diff options
author | uzvkl <dennis.kobert@student.kit.edu> | 2019-06-11 22:46:57 +0200 |
---|---|---|
committer | uzvkl <dennis.kobert@student.kit.edu> | 2019-06-11 22:46:57 +0200 |
commit | 2490ad5d31fe2ac778ff9303776f0e91f47a2862 (patch) | |
tree | 4b2b2b284897cd239ecbc3a2d4efa6d5d103057f /DSACore/Models | |
parent | c80384ca8b729677d78934476e7b193b5327ae40 (diff) |
Organize groups to seperate connention management form gamelogic
Diffstat (limited to 'DSACore/Models')
-rw-r--r-- | DSACore/Models/Network/Group.cs | 43 | ||||
-rw-r--r-- | DSACore/Models/Network/Token.cs | 21 | ||||
-rw-r--r-- | DSACore/Models/Network/User.cs | 9 |
3 files changed, 73 insertions, 0 deletions
diff --git a/DSACore/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs new file mode 100644 index 0000000..efe12ee --- /dev/null +++ b/DSACore/Models/Network/Group.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; + +namespace DSACore.Models.Network +{ + public class Group + { + public Group(string name, string password) + { + Name = name; + Password = password; + } + + public Group(string name, int userOnline) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + } + + public string Name { get; set; } + public string Password { get; set; } + public List<User> Users { get; set; } = new List<User>(); + + public int UserCount => Users.Count; + + public SendGroup SendGroup() + { + return new SendGroup(Name, UserCount); + } + } + + public class SendGroup + { + public SendGroup(string name, int userCount) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + UserCount = userCount; + } + + public string Name { get; set; } + + public int UserCount { get; set; } + } +}
\ No newline at end of file diff --git a/DSACore/Models/Network/Token.cs b/DSACore/Models/Network/Token.cs new file mode 100644 index 0000000..451cafc --- /dev/null +++ b/DSACore/Models/Network/Token.cs @@ -0,0 +1,21 @@ +using System; + +namespace DSACore.Models.Network +{ + public class Token + { + private readonly DateTime creation = DateTime.Now; + + public Token(string group) + { + Group = group; + } + + public string Group { get; set; } + + public bool IsValid() + { + return DateTime.Now - creation < TimeSpan.FromMinutes(1); + } + } +}
\ No newline at end of file diff --git a/DSACore/Models/Network/User.cs b/DSACore/Models/Network/User.cs new file mode 100644 index 0000000..8b8008c --- /dev/null +++ b/DSACore/Models/Network/User.cs @@ -0,0 +1,9 @@ +namespace DSACore.Models.Network +{ + public class User + { + public string Name { get; set; } + public string ConnectionId { get; set; } + public int Char { get; set; } + } +}
\ No newline at end of file |