mirror of
				https://github.com/CommonLoon102/NBloodServerSupervisor.git
				synced 2025-11-03 23:37:25 +01:00 
			
		
		
		
	remove server from the list when it quits (#1)
* remove server from the list when it quits * remove whitespace
This commit is contained in:
		
							parent
							
								
									cbccbcf0d2
								
							
						
					
					
						commit
						dd95382d08
					
				@ -5,6 +5,7 @@ using System.Linq;
 | 
			
		||||
using System.Net;
 | 
			
		||||
using System.Net.Sockets;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading;
 | 
			
		||||
 | 
			
		||||
namespace Supervisor
 | 
			
		||||
{
 | 
			
		||||
@ -37,6 +38,9 @@ namespace Supervisor
 | 
			
		||||
                case 'C':
 | 
			
		||||
                    ProcessFragsPacket(buffer);
 | 
			
		||||
                    break;
 | 
			
		||||
                case 'D':
 | 
			
		||||
                    ProcessRemovePacket(message);
 | 
			
		||||
                    break;
 | 
			
		||||
                default:
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
@ -150,6 +154,27 @@ namespace Supervisor
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static void ProcessRemovePacket(string message)
 | 
			
		||||
        {
 | 
			
		||||
            string[] splitMessage = message.SplitMessage();
 | 
			
		||||
            var packetData = new RemoveServer()
 | 
			
		||||
            {
 | 
			
		||||
                Port = int.Parse(splitMessage[0])
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            UpdateState(packetData);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static void UpdateState(RemoveServer packetData)
 | 
			
		||||
        {
 | 
			
		||||
            bool isSuccess;
 | 
			
		||||
            do
 | 
			
		||||
            {
 | 
			
		||||
                isSuccess = Program.State.Servers.TryRemove(packetData.Port, out _);
 | 
			
		||||
                Thread.Sleep(TimeSpan.FromSeconds(1));
 | 
			
		||||
            } while (!isSuccess);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static string GetGameType(int gameType)
 | 
			
		||||
        {
 | 
			
		||||
            return gameType switch
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								Supervisor/Packets/RemoveServer.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								Supervisor/Packets/RemoveServer.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
 | 
			
		||||
namespace Supervisor
 | 
			
		||||
{
 | 
			
		||||
    class RemoveServer : PacketData
 | 
			
		||||
    {
 | 
			
		||||
        public RemoveServer()
 | 
			
		||||
        {
 | 
			
		||||
            IsStarted = false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								WebInterface/Supervisor.runtimeconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								WebInterface/Supervisor.runtimeconfig.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
{
 | 
			
		||||
    "runtimeOptions": {
 | 
			
		||||
        "tfm": "netcoreapp3.1",
 | 
			
		||||
        "framework": {
 | 
			
		||||
            "name": "Microsoft.NETCore.App",
 | 
			
		||||
            "version": "3.1.0"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -12,6 +12,7 @@
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ProjectReference Include="..\Common\Common.csproj" />
 | 
			
		||||
    <ProjectReference Include="..\Model\Model.csproj" />
 | 
			
		||||
    <ProjectReference Include="..\Supervisor\Supervisor.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user