From 35ca016520628d65f6acea42d76a3d0f2ecbdb81 Mon Sep 17 00:00:00 2001 From: Edmand46 Date: Wed, 18 May 2022 22:17:25 +0400 Subject: [PATCH] chore: move to thread application logic, updated logo --- Images/{logo.png => ragon-logo.png} | Bin Ragon/Sources/Application.cs | 20 ++++++++++++++------ Ragon/Sources/Bootstrap.cs | 8 ++++++-- readme.md | 3 ++- 4 files changed, 22 insertions(+), 9 deletions(-) rename Images/{logo.png => ragon-logo.png} (100%) diff --git a/Images/logo.png b/Images/ragon-logo.png similarity index 100% rename from Images/logo.png rename to Images/ragon-logo.png diff --git a/Ragon/Sources/Application.cs b/Ragon/Sources/Application.cs index 8daa644..1a84066 100755 --- a/Ragon/Sources/Application.cs +++ b/Ragon/Sources/Application.cs @@ -16,6 +16,8 @@ namespace Ragon.Core private readonly ENetServer _socketServer; private int _roomThreadBalancer = 0; + private Thread _thread; + public Application(PluginFactory factory, Configuration configuration, int threadsCount) { _socketServer = new ENetServer(); @@ -29,13 +31,8 @@ namespace Ragon.Core } } - public void Start() + private void Loop() { - _socketServer.Start(_configuration.Server.Port); - - foreach (var roomThread in _roomThreads) - roomThread.Start(); - while (true) { foreach (var roomThread in _roomThreads) @@ -79,6 +76,17 @@ namespace Ragon.Core } } + public void Start() + { + _socketServer.Start(_configuration.Server.Port); + + foreach (var roomThread in _roomThreads) + roomThread.Start(); + + _thread = new Thread(Loop); + _thread.Start(); + } + public void Dispose() { foreach (var roomThread in _roomThreads) diff --git a/Ragon/Sources/Bootstrap.cs b/Ragon/Sources/Bootstrap.cs index 6584ef4..6a098b9 100755 --- a/Ragon/Sources/Bootstrap.cs +++ b/Ragon/Sources/Bootstrap.cs @@ -1,4 +1,7 @@ -using NLog; +using System; +using System.Diagnostics; +using System.IO; +using NLog; namespace Ragon.Core { @@ -9,7 +12,8 @@ namespace Ragon.Core public void Configure(PluginFactory factory) { _logger.Info("Configure application..."); - var configuration = ConfigurationLoader.Load("config.json"); + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json"); + var configuration = ConfigurationLoader.Load(filePath); var app = new Application(factory, configuration, 2); app.Start(); } diff --git a/readme.md b/readme.md index 28334dd..2839b05 100755 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@

- +

## Ragon Server @@ -37,6 +37,7 @@ Ragon is fully free high perfomance room based game server with plugin based arc ### Requirements - OSX, Windows, Linux(Ubuntu, Debian) - .NET 6.0 + ### Dependencies * ENet-Sharp v2.4.8 * NetStack latest