Skip to content

Commit

Permalink
Merge pull request #122 from CodewareGames/owsdata-owsshared-dependen…
Browse files Browse the repository at this point in the history
…cyfix

OWSData OWSShared Dependency Loop Fix
  • Loading branch information
Dartanlla authored Oct 18, 2023
2 parents a734fc3 + 0a9fabb commit ac6993c
Show file tree
Hide file tree
Showing 37 changed files with 69 additions and 79 deletions.
1 change: 1 addition & 0 deletions src/OWSCharacterPersistence/OWSCharacterPersistence.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OWSData\OWSData.csproj" />
<ProjectReference Include="..\OWSShared\OWSShared.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/OWSCharacterPersistence/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void ConfigureServices(IServiceCollection services)
c.IncludeXmlComments(filePath);
});

services.Configure<OWSData.Models.StorageOptions>(Configuration.GetSection(OWSData.Models.StorageOptions.SectionName));
services.Configure<OWSShared.Options.StorageOptions>(Configuration.GetSection(OWSShared.Options.StorageOptions.SectionName));
services.Configure<OWSShared.Options.APIPathOptions>(Configuration.GetSection(OWSShared.Options.APIPathOptions.SectionName));
services.Configure<OWSShared.Options.RabbitMQOptions>(Configuration.GetSection(OWSShared.Options.RabbitMQOptions.SectionName));

Expand Down
4 changes: 4 additions & 0 deletions src/OWSData/OWSData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OWSShared\OWSShared.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.InMemory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using OWSData.Models.Composites;
using OWSData.Models.Tables;
using OWSData.SQL;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MSSQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Data;
using System.Data.SqlClient;
using System.Threading.Tasks;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MSSQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Data.SqlClient;
using System.Text;
using System.Threading.Tasks;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MSSQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using OWSData.Models.Tables;
using OWSData.Repositories.Interfaces;
using OWSData.SQL;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MSSQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using OWSData.Repositories.Implementations.MongoDB.Models;
using Microsoft.Extensions.Configuration;
using System.Threading.Tasks;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MongoDB
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using OWSData.Repositories.Interfaces;
using OWSData.Models.Tables;
using OWSData.SQL;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MySQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using OWSData.Repositories.Interfaces;
using OWSData.Models.Tables;
using OWSData.SQL;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MySQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using OWSData.Models.StoredProcs;
using OWSData.Repositories.Interfaces;
using OWSData.SQL;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MySQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using OWSData.Repositories.Interfaces;
using OWSData.SQL;
using OWSData.Models.Tables;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.MySQL
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using OWSData.Repositories.Interfaces;
using OWSData.Models.Tables;
using OWSData.SQL;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.Postgres
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using OWSData.Repositories.Interfaces;
using OWSData.Models.Tables;
using OWSData.SQL;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.Postgres
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using OWSData.Models.StoredProcs;
using OWSData.Repositories.Interfaces;
using OWSData.SQL;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.Postgres
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using OWSData.Repositories.Interfaces;
using OWSData.SQL;
using OWSData.Models.Tables;
using OWSShared.Options;

namespace OWSData.Repositories.Implementations.Postgres
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using OWSShared.Options;

namespace OWSData.Repositories.Interfaces
{
Expand Down
1 change: 1 addition & 0 deletions src/OWSGlobalData/OWSGlobalData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OWSData\OWSData.csproj" />
<ProjectReference Include="..\OWSShared\OWSShared.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/OWSGlobalData/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void ConfigureServices(IServiceCollection services)
c.IncludeXmlComments(filePath);
});

services.Configure<OWSData.Models.StorageOptions>(Configuration.GetSection(OWSData.Models.StorageOptions.SectionName));
services.Configure<OWSShared.Options.StorageOptions>(Configuration.GetSection(OWSShared.Options.StorageOptions.SectionName));
services.Configure<OWSShared.Options.APIPathOptions>(Configuration.GetSection(OWSShared.Options.APIPathOptions.SectionName));
services.Configure<OWSShared.Options.RabbitMQOptions>(Configuration.GetSection(OWSShared.Options.RabbitMQOptions.SectionName));

Expand Down
1 change: 0 additions & 1 deletion src/OWSInstanceLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using OWSShared.Objects;
using Serilog;

namespace OWSInstanceLauncher
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using OWSData.Models;
using OWSData.Models.StoredProcs;
using OWSData.Repositories.Interfaces;
using OWSShared.Interfaces;
using OWSShared.Messages;
using OWSShared.RequestPayloads;
using OWSShared.Options;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Text.Json;
using Serilog;
using MongoDB.Driver.Linq;

namespace OWSShared.Objects
namespace OWSInstanceLauncher.Services
{
public class ServerLauncherHealthMonitoring : IServerHealthMonitoringJob
{
Expand All @@ -25,7 +22,7 @@ public class ServerLauncherHealthMonitoring : IServerHealthMonitoringJob
private readonly IZoneServerProcessesRepository _zoneServerProcessesRepository;
private readonly IOWSInstanceLauncherDataRepository _owsInstanceLauncherDataRepository;

public ServerLauncherHealthMonitoring(IOptions<OWSInstanceLauncherOptions> OWSInstanceLauncherOptions, IHttpClientFactory httpClientFactory, IZoneServerProcessesRepository zoneServerProcessesRepository,
public ServerLauncherHealthMonitoring(IOptions<OWSInstanceLauncherOptions> OWSInstanceLauncherOptions, IHttpClientFactory httpClientFactory, IZoneServerProcessesRepository zoneServerProcessesRepository,
IOWSInstanceLauncherDataRepository owsInstanceLauncherDataRepository)
{
_OWSInstanceLauncherOptions = OWSInstanceLauncherOptions;
Expand Down Expand Up @@ -80,7 +77,7 @@ private List<GetZoneInstancesForWorldServer> GetZoneInstancesForWorldServer(int
}
};

var shutDownInstanceLauncherRequest = new StringContent(JsonConvert.SerializeObject(worldServerIDRequestPayload), Encoding.UTF8, "application/json");
var shutDownInstanceLauncherRequest = new StringContent(JsonSerializer.Serialize(worldServerIDRequestPayload), Encoding.UTF8, "application/json");

var responseMessageTask = instanceManagementHttpClient.PostAsync("api/Instance/GetZoneInstancesForWorldServer", shutDownInstanceLauncherRequest);
var responseMessage = responseMessageTask.Result;
Expand All @@ -89,9 +86,9 @@ private List<GetZoneInstancesForWorldServer> GetZoneInstancesForWorldServer(int
{
var responseContentAsync = responseMessage.Content.ReadAsStringAsync();
string responseContentString = responseContentAsync.Result;
output = JsonConvert.DeserializeObject<List<GetZoneInstancesForWorldServer>>(responseContentString);
}
else
output = JsonSerializer.Deserialize<List<GetZoneInstancesForWorldServer>>(responseContentString);
}
else
{
output = new List<GetZoneInstancesForWorldServer>();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using OWSData.Models;
using OWSData.Repositories.Interfaces;
using OWSShared.Interfaces;
Expand All @@ -10,15 +9,13 @@
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Text.Json;
using System.Threading.Tasks;
using Serilog;

namespace OWSShared.Objects
namespace OWSInstanceLauncher.Services
{
public class ServerLauncherMQListener : IInstanceLauncherJob //BackgroundService
{
Expand Down Expand Up @@ -254,10 +251,10 @@ private void HandleServerSpinUpMessage(Guid customerGUID, int worldServerID, int
//string PathToDedicatedServer = "E:\\Program Files\\Epic Games\\UE_4.25\\Engine\\Binaries\\Win64\\UE4Editor.exe";
//string ServerArguments = "\"C:\\OWS\\OpenWorldStarterPlugin\\OpenWorldStarter.uproject\" {0}?listen -server -log -nosteam -messaging -port={1}";

string serverArguments = (_owsInstanceLauncherOptions.Value.IsServerEditor ? "\"" + _owsInstanceLauncherOptions.Value.PathToUProject + "\" ": "")
string serverArguments = (_owsInstanceLauncherOptions.Value.IsServerEditor ? "\"" + _owsInstanceLauncherOptions.Value.PathToUProject + "\" " : "")
+ "{0}?listen -server "
+ (_owsInstanceLauncherOptions.Value.UseServerLog ? "-log " : "")
+ (_owsInstanceLauncherOptions.Value.UseNoSteam ? "-nosteam " : "")
+ (_owsInstanceLauncherOptions.Value.UseServerLog ? "-log " : "")
+ (_owsInstanceLauncherOptions.Value.UseNoSteam ? "-nosteam " : "")
+ "-port={1} "
+ "-zoneinstanceid={2}";

Expand All @@ -276,7 +273,8 @@ private void HandleServerSpinUpMessage(Guid customerGUID, int worldServerID, int
proc.Start();
//proc.WaitForInputIdle();

_zoneServerProcessesRepository.AddZoneServerProcess(new ZoneServerProcess {
_zoneServerProcessesRepository.AddZoneServerProcess(new ZoneServerProcess
{
ZoneInstanceId = zoneInstanceID,
MapName = mapName,
Port = port,
Expand Down Expand Up @@ -350,7 +348,7 @@ private int RegisterInstanceLauncherRequest()
}
};

var RegisterLauncherPayloadRequest = new StringContent(JsonConvert.SerializeObject(RegisterLauncherPayload), Encoding.UTF8, "application/json");
var RegisterLauncherPayloadRequest = new StringContent(JsonSerializer.Serialize(RegisterLauncherPayload), Encoding.UTF8, "application/json");

var responseMessageAsync = instanceManagementHttpClient.PostAsync("api/Instance/RegisterLauncher", RegisterLauncherPayloadRequest);
var responseMessage = responseMessageAsync.Result;
Expand Down Expand Up @@ -431,7 +429,7 @@ private async Task ShutDownInstanceLauncherRequest(int worldServerId)
}
};

var shutDownInstanceLauncherRequest = new StringContent(JsonConvert.SerializeObject(worldServerIDRequestPayload), Encoding.UTF8, "application/json");
var shutDownInstanceLauncherRequest = new StringContent(JsonSerializer.Serialize(worldServerIDRequestPayload), Encoding.UTF8, "application/json");

var request = new HttpRequestMessage()
{
Expand All @@ -450,16 +448,16 @@ private async Task UpdateZoneServerStatusReady(int zoneInstanceID)
{
var instanceManagementHttpClient = _httpClientFactory.CreateClient("OWSInstanceManagement");

var setZoneInstanceStatusRequestPayload = new
{
var setZoneInstanceStatusRequestPayload = new
{
request = new SetZoneInstanceStatusRequestPayload
{
ZoneInstanceID = zoneInstanceID,
InstanceStatus = 2 //Ready
}
};

var setZoneInstanceStatusRequest = new StringContent(JsonConvert.SerializeObject(setZoneInstanceStatusRequestPayload), Encoding.UTF8, "application/json");
var setZoneInstanceStatusRequest = new StringContent(JsonSerializer.Serialize(setZoneInstanceStatusRequestPayload), Encoding.UTF8, "application/json");

var responseMessage = await instanceManagementHttpClient.PostAsync("api/Instance/SetZoneInstanceStatus", setZoneInstanceStatusRequest);

Expand Down
7 changes: 7 additions & 0 deletions src/OWSInstanceLauncher/Services/ServerLauncherShutDown.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OWSInstanceLauncher.Services
{
public class ServerLauncherShutDown
{

}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using SimpleInjector;
using SimpleInjector.Lifestyles;

namespace OWSShared.Objects

namespace OWSInstanceLauncher.Services
{
public class TimedHostedService<TService> : IHostedService, IDisposable
where TService : class
public class TimedHostedService<TService> : IHostedService, IDisposable where TService : class
{
private readonly SimpleInjector.Container container;
private readonly Settings settings;
Expand Down Expand Up @@ -98,4 +93,4 @@ public Settings(TimeSpan interval, bool runOnce, Action<TService> action, Action
}
}
}
}
}
10 changes: 5 additions & 5 deletions src/OWSInstanceLauncher/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
using OWSShared.Implementations;
using OWSShared.Interfaces;
using OWSShared.Messages;
using OWSShared.Objects;
using SimpleInjector;
using Serilog;
using OWSInstanceLauncher.Services;

namespace OWSInstanceLauncher
{
public class Startup
{
//Container container;
private Container container = new SimpleInjector.Container();
private OWSData.Models.OWSInstanceLauncherOptions owsInstanceLauncherOptions;
private OWSShared.Options.OWSInstanceLauncherOptions owsInstanceLauncherOptions;

public IConfiguration Configuration { get; }

Expand All @@ -39,8 +39,8 @@ public Startup(IConfiguration configuration)

Configuration = configuration;

owsInstanceLauncherOptions = new OWSData.Models.OWSInstanceLauncherOptions();
Configuration.GetSection(OWSData.Models.OWSInstanceLauncherOptions.SectionName).Bind(owsInstanceLauncherOptions);
owsInstanceLauncherOptions = new OWSShared.Options.OWSInstanceLauncherOptions();
Configuration.GetSection(OWSShared.Options.OWSInstanceLauncherOptions.SectionName).Bind(owsInstanceLauncherOptions);

//Check appsettings.json file for potential errors
bool thereWasAStartupError = false;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void ConfigureServices(IServiceCollection services)
.AddViews()
.AddApiExplorer();

services.ConfigureWritable<OWSData.Models.OWSInstanceLauncherOptions>(Configuration.GetSection(OWSData.Models.OWSInstanceLauncherOptions.SectionName));
services.ConfigureWritable<OWSShared.Options.OWSInstanceLauncherOptions>(Configuration.GetSection(OWSShared.Options.OWSInstanceLauncherOptions.SectionName));
services.Configure<OWSShared.Options.APIPathOptions>(Configuration.GetSection(OWSShared.Options.APIPathOptions.SectionName));
services.Configure<OWSShared.Options.RabbitMQOptions>(Configuration.GetSection(OWSShared.Options.RabbitMQOptions.SectionName));

Expand Down
Loading

0 comments on commit ac6993c

Please sign in to comment.