]> git.deb.at Git - rhonda/impostor.git/commitdiff
Clean up client manager
authorAeonLucid <aeonlucid@outlook.com>
Sun, 25 Oct 2020 23:10:06 +0000 (00:10 +0100)
committerAeonLucid <aeonlucid@outlook.com>
Sun, 25 Oct 2020 23:10:06 +0000 (00:10 +0100)
src/Impostor.Api/Impostor.Api.csproj
src/Impostor.Api/Innersloth/TextBox.cs [new file with mode: 0644]
src/Impostor.Plugins.Example/Impostor.Plugins.Example.csproj
src/Impostor.Server/Net/Manager/ClientManager.Api.cs [new file with mode: 0644]
src/Impostor.Server/Net/Manager/ClientManager.cs

index d0a90e0c6660a039be647acbfe7a39023da253d2..5b31db727c34b5bc54422b86f146a2063ca97da9 100644 (file)
@@ -22,9 +22,9 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0"/>
-    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0-rc.1.20451.14"/>
-    <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0-rc.1.20451.14"/>
+    <PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
+    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0-rc.1.20451.14" />
+    <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0-rc.1.20451.14" />
     <PackageReference Include="Nullable" Version="1.3.0">
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
diff --git a/src/Impostor.Api/Innersloth/TextBox.cs b/src/Impostor.Api/Innersloth/TextBox.cs
new file mode 100644 (file)
index 0000000..9533d83
--- /dev/null
@@ -0,0 +1,10 @@
+namespace Impostor.Api.Innersloth
+{
+    public static class TextBox
+    {
+        public static bool IsCharAllowed(char i)
+        {
+            return i == ' ' || (i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || (i >= '0' && i <= '9') || (i >= 'À' && i <= 'ÿ') || (i >= 'Ѐ' && i <= 'џ') || (i >= 'ㄱ' && i <= 'ㆎ') || (i >= '가' && i <= '힣');
+        }
+    }
+}
\ No newline at end of file
index 582a9e801f4e56592d8b85b0fae4321a52aeda41..0cd6cd524c67393fa1d41ee7d6592382a7625c62 100644 (file)
@@ -1,10 +1,11 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
-    <PropertyGroup>
-        <TargetFramework>netstandard2.1</TargetFramework>
-    </PropertyGroup>
+  <PropertyGroup>
+    <TargetFramework>netstandard2.1</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\Impostor.Api\Impostor.Api.csproj"/>
+  </ItemGroup>
 
-    <ItemGroup>
-        <ProjectReference Include="..\Impostor.Api\Impostor.Api.csproj" />
-    </ItemGroup>
 </Project>
diff --git a/src/Impostor.Server/Net/Manager/ClientManager.Api.cs b/src/Impostor.Server/Net/Manager/ClientManager.Api.cs
new file mode 100644 (file)
index 0000000..6cbe5bf
--- /dev/null
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Manager;
+
+namespace Impostor.Server.Net.Manager
+{
+    internal partial class ClientManager : IClientManager
+    {
+        IEnumerable<IClient> IClientManager.Clients => _clients.Values;
+    }
+}
\ No newline at end of file
index 5fbe823c46fb59588c2edde0a15d9551f2dea9c9..96b2f54b8c1b67a9f51db1cc480c79640b90ee33 100644 (file)
@@ -15,9 +15,9 @@ using Microsoft.Extensions.Logging;
 
 namespace Impostor.Server.Net.Manager
 {
-    internal class ClientManager : IClientManager
+    internal partial class ClientManager
     {
-        public static HashSet<int> SupportedVersions { get; } = new HashSet<int>
+        private static HashSet<int> SupportedVersions { get; } = new HashSet<int>
         {
             GameVersion.GetVersion(2020, 09, 07), // 2020.09.07 - 2020.09.22
             GameVersion.GetVersion(2020, 10, 08), // 2020.10.08
@@ -37,8 +37,6 @@ namespace Impostor.Server.Net.Manager
 
         public IEnumerable<ClientBase> Clients => _clients.Values;
 
-        IEnumerable<IClient> IClientManager.Clients => _clients.Values;
-
         public int NextId()
         {
             var clientId = Interlocked.Increment(ref _idLast);
@@ -55,11 +53,6 @@ namespace Impostor.Server.Net.Manager
             return clientId;
         }
 
-        private static bool IsCharAllowed(char i)
-        {
-            return i == ' ' || (i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || (i >= '0' && i <= '9') || (i >= 'À' && i <= 'ÿ') || (i >= 'Ѐ' && i <= 'џ') || (i >= 'ㄱ' && i <= 'ㆎ') || (i >= '가' && i <= '힣');
-        }
-
         public async ValueTask RegisterConnectionAsync(IHazelConnection connection, string name, int clientVersion)
         {
             if (!SupportedVersions.Contains(clientVersion))
@@ -78,7 +71,7 @@ namespace Impostor.Server.Net.Manager
                 return;
             }
 
-            if (string.IsNullOrWhiteSpace(name) || !name.All(IsCharAllowed))
+            if (string.IsNullOrWhiteSpace(name) || !name.All(TextBox.IsCharAllowed))
             {
                 using var packet = MessageWriter.Get(MessageType.Reliable);
                 Message01JoinGameS2C.SerializeError(packet, false, DisconnectReason.Custom, DisconnectMessages.UsernameIllegalCharacters);