summaryrefslogtreecommitdiff
path: root/DSALib/Models/Network
diff options
context:
space:
mode:
Diffstat (limited to 'DSALib/Models/Network')
-rw-r--r--DSALib/Models/Network/Command.cs18
-rw-r--r--DSALib/Models/Network/CommandResponse.cs28
-rw-r--r--DSALib/Models/Network/Group.cs43
-rw-r--r--DSALib/Models/Network/Token.cs21
-rw-r--r--DSALib/Models/Network/User.cs9
5 files changed, 119 insertions, 0 deletions
diff --git a/DSALib/Models/Network/Command.cs b/DSALib/Models/Network/Command.cs
new file mode 100644
index 0000000..00b00a6
--- /dev/null
+++ b/DSALib/Models/Network/Command.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace DSACore.Models.Network
+{
+ public class Command
+ {
+ public ulong GroupId { get; set; } = 0;
+ public ulong CharId { get; set; }
+ public string Name { get; set; }
+ public string CmdIdentifier { get; set; }
+ public List<string> CmdTexts { get; set; }
+ public string CmdText => CmdTexts.Count != 0 ? CmdTexts.First() : "";
+
+ public int Cmdmodifier => CmdTexts.Count != 0 && int.TryParse(CmdTexts.Last(), out var mod) ? mod : 0;
+ public bool IsDm { get; set; } = false;
+ }
+} \ No newline at end of file
diff --git a/DSALib/Models/Network/CommandResponse.cs b/DSALib/Models/Network/CommandResponse.cs
new file mode 100644
index 0000000..c7a410a
--- /dev/null
+++ b/DSALib/Models/Network/CommandResponse.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace DSACore.Models.Network
+{
+ public class CommandResponse
+ {
+ public CommandResponse(string message, ResponseType responseType = ResponseType.Broadcast)
+ {
+ this.message = message ?? throw new ArgumentNullException(nameof(message));
+ ResponseType = responseType;
+ }
+
+ public string message { get; }
+ public ResponseType ResponseType { get; }
+
+ public override string ToString()
+ {
+ return message;
+ }
+ }
+
+ public enum ResponseType
+ {
+ Broadcast,
+ Caller,
+ Error
+ }
+} \ No newline at end of file
diff --git a/DSALib/Models/Network/Group.cs b/DSALib/Models/Network/Group.cs
new file mode 100644
index 0000000..efe12ee
--- /dev/null
+++ b/DSALib/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/DSALib/Models/Network/Token.cs b/DSALib/Models/Network/Token.cs
new file mode 100644
index 0000000..451cafc
--- /dev/null
+++ b/DSALib/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/DSALib/Models/Network/User.cs b/DSALib/Models/Network/User.cs
new file mode 100644
index 0000000..8b8008c
--- /dev/null
+++ b/DSALib/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