chore: move to thread application logic, updated logo

This commit is contained in:
2022-05-18 22:17:25 +04:00
parent 8481cb89ad
commit 35ca016520
4 changed files with 22 additions and 9 deletions
+14 -6
View File
@@ -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)
+6 -2
View File
@@ -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();
}