-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Seperate server executeable and api controllers
- Loading branch information
1 parent
8dec8da
commit 946fada
Showing
26 changed files
with
202 additions
and
179 deletions.
There are no files selected for viewing
5 changes: 3 additions & 2 deletions
5
BeatTogether.Status.Api.csproj → ...eatTogether.Status.Api.Controllers.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions
22
Configuration/QuickplayConfiguration.cs → ...s/Configuration/QuickplayConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
using BeatTogether.Status.Api.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Configuration | ||
{ | ||
public class QuickplayConfiguration | ||
{ | ||
public List<PredefinedPack> PredefinedPacks { get; set; } = new(); | ||
public List<LocalizedCustomPack> LocalizedCustomPacks { get; set; } = new(); | ||
} | ||
} | ||
using BeatTogether.Status.Api.Controllers.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Configuration | ||
{ | ||
public class QuickplayConfiguration | ||
{ | ||
public List<PredefinedPack> PredefinedPacks { get; set; } = new(); | ||
public List<LocalizedCustomPack> LocalizedCustomPacks { get; set; } = new(); | ||
} | ||
} |
50 changes: 25 additions & 25 deletions
50
Configuration/StatusConfiguration.cs → ...lers/Configuration/StatusConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
using System.Collections.Generic; | ||
using BeatTogether.Status.Api.Models; | ||
|
||
namespace BeatTogether.Status.Api.Configuration | ||
{ | ||
public class StatusConfiguration | ||
{ | ||
public string MinimumAppVersion { get; set; } = "1.0.0"; | ||
public long MaintenanceStartTime { get; set; } | ||
public long MaintenanceEndTime { get; set; } | ||
public List<LocalizedMessage> LocalizedMessages { get; set; } = new(); | ||
public List<RequiredMod> RequiredMods { get; set; } = new(); | ||
/// <summary> | ||
/// Prefer SSL (DTLS) for dedicated server connections? | ||
/// </summary> | ||
public bool UseSsl { get; set; } = false; | ||
public string ServerDisplayName { get; set; } = string.Empty; | ||
public string ServerDescription { get; set; } = string.Empty; | ||
public string ServerImageUrl { get; set; } = string.Empty; | ||
public int MaxPlayers { get; set; } = 25; | ||
public bool ServerSupportsPpModifiers { get; set; } = false; | ||
public bool ServerSupportsPpDifficulties { get; set; } = false; | ||
public bool ServerSupportsPpMaps { get; set; } = false; | ||
} | ||
} | ||
using System.Collections.Generic; | ||
using BeatTogether.Status.Api.Controllers.Models; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Configuration | ||
{ | ||
public class StatusConfiguration | ||
{ | ||
public string MinimumAppVersion { get; set; } = "1.0.0"; | ||
public long MaintenanceStartTime { get; set; } | ||
public long MaintenanceEndTime { get; set; } | ||
public List<LocalizedMessage> LocalizedMessages { get; set; } = new(); | ||
public List<RequiredMod> RequiredMods { get; set; } = new(); | ||
/// <summary> | ||
/// Prefer SSL (DTLS) for dedicated server connections? | ||
/// </summary> | ||
public bool UseSsl { get; set; } = false; | ||
public string ServerDisplayName { get; set; } = string.Empty; | ||
public string ServerDescription { get; set; } = string.Empty; | ||
public string ServerImageUrl { get; set; } = string.Empty; | ||
public int MaxPlayers { get; set; } = 25; | ||
public bool ServerSupportsPpModifiers { get; set; } = false; | ||
public bool ServerSupportsPpDifficulties { get; set; } = false; | ||
public bool ServerSupportsPpMaps { get; set; } = false; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
Controllers/QuickplayController.cs → ...ollers/Controllers/QuickplayController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 48 additions & 48 deletions
96
Controllers/StatusController.cs → ...ntrollers/Controllers/StatusController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
using System; | ||
using BeatTogether.Status.Api.Configuration; | ||
using BeatTogether.Status.Api.Enums; | ||
using BeatTogether.Status.Api.Models; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace BeatTogether.Status.Api.Controllers | ||
{ | ||
[ApiController] | ||
[Route("status")] | ||
public class StatusController : ControllerBase | ||
{ | ||
private readonly StatusConfiguration _configuration; | ||
|
||
public StatusController(IOptionsSnapshot<StatusConfiguration> configuration) | ||
{ | ||
_configuration = configuration.Value; | ||
} | ||
|
||
[HttpGet] | ||
public MasterServerStatusData Get() | ||
{ | ||
var status = AvailabilityStatus.Online; | ||
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); | ||
if (timestamp < _configuration.MaintenanceStartTime) | ||
status = AvailabilityStatus.MaintenanceUpcoming; | ||
else if (timestamp < _configuration.MaintenanceEndTime) | ||
status = AvailabilityStatus.Offline; | ||
return new MasterServerStatusData( | ||
_configuration.MinimumAppVersion, | ||
status, | ||
_configuration.MaintenanceStartTime, | ||
_configuration.MaintenanceEndTime, | ||
new UserMessage(_configuration.LocalizedMessages), | ||
_configuration.RequiredMods, | ||
_configuration.UseSsl, | ||
_configuration.ServerDisplayName, | ||
_configuration.ServerDescription, | ||
_configuration.ServerImageUrl, | ||
_configuration.MaxPlayers, | ||
_configuration.ServerSupportsPpModifiers, | ||
_configuration.ServerSupportsPpDifficulties, | ||
_configuration.ServerSupportsPpMaps | ||
); | ||
} | ||
} | ||
} | ||
using System; | ||
using BeatTogether.Status.Api.Controllers.Configuration; | ||
using BeatTogether.Status.Api.Controllers.Enums; | ||
using BeatTogether.Status.Api.Controllers.Models; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Controllers | ||
{ | ||
[ApiController] | ||
[Route("status")] | ||
public class StatusController : ControllerBase | ||
{ | ||
private readonly StatusConfiguration _configuration; | ||
|
||
public StatusController(IOptionsSnapshot<StatusConfiguration> configuration) | ||
{ | ||
_configuration = configuration.Value; | ||
} | ||
|
||
[HttpGet] | ||
public MasterServerStatusData Get() | ||
{ | ||
var status = AvailabilityStatus.Online; | ||
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); | ||
if (timestamp < _configuration.MaintenanceStartTime) | ||
status = AvailabilityStatus.MaintenanceUpcoming; | ||
else if (timestamp < _configuration.MaintenanceEndTime) | ||
status = AvailabilityStatus.Offline; | ||
return new MasterServerStatusData( | ||
_configuration.MinimumAppVersion, | ||
status, | ||
_configuration.MaintenanceStartTime, | ||
_configuration.MaintenanceEndTime, | ||
new UserMessage(_configuration.LocalizedMessages), | ||
_configuration.RequiredMods, | ||
_configuration.UseSsl, | ||
_configuration.ServerDisplayName, | ||
_configuration.ServerDescription, | ||
_configuration.ServerImageUrl, | ||
_configuration.MaxPlayers, | ||
_configuration.ServerSupportsPpModifiers, | ||
_configuration.ServerSupportsPpDifficulties, | ||
_configuration.ServerSupportsPpMaps | ||
); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Enums/AvailabilityStatus.cs → ...i.Controllers/Enums/AvailabilityStatus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Enums/Language.cs → ....Status.Api.Controllers/Enums/Language.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
BeatTogether.Status.Api.Controllers/Extensions/HostBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.Extensions.Hosting; | ||
using BeatTogether.Extensions; | ||
using BeatTogether.Status.Api.Controllers.Configuration; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Extensions | ||
{ | ||
public static class HostBuilderExtensions | ||
{ | ||
public static IHostBuilder UseStatusServer(this IHostBuilder hostBuilder) => | ||
hostBuilder | ||
.ConfigureAppConfiguration() | ||
.ConfigureServices((hostBuilderContext, services) => | ||
services | ||
.Configure<StatusConfiguration>(hostBuilderContext.Configuration.GetSection("Status")) | ||
.Configure<QuickplayConfiguration>(hostBuilderContext.Configuration.GetSection("Quickplay")) | ||
); | ||
} | ||
} |
24 changes: 12 additions & 12 deletions
24
Models/LocalizedCustomPack.cs → ...Controllers/Models/LocalizedCustomPack.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public class LocalizedCustomPack | ||
{ | ||
public string serializedName { get; set; } = string.Empty; | ||
public int order { get; set; } | ||
public List<LocalizedCustomPackName> localizedNames { get; set; } = new(); | ||
public List<string> packIds { get; set; } = new(); | ||
} | ||
} | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public class LocalizedCustomPack | ||
{ | ||
public string serializedName { get; set; } = string.Empty; | ||
public int order { get; set; } | ||
public List<LocalizedCustomPackName> localizedNames { get; set; } = new(); | ||
public List<string> packIds { get; set; } = new(); | ||
} | ||
} |
20 changes: 10 additions & 10 deletions
20
Models/LocalizedCustomPackName.cs → ...rollers/Models/LocalizedCustomPackName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using BeatTogether.Status.Api.Enums; | ||
|
||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public class LocalizedCustomPackName | ||
{ | ||
public Language language { get; set; } | ||
public string packName { get; set; } = string.Empty; | ||
} | ||
} | ||
using BeatTogether.Status.Api.Controllers.Enums; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public class LocalizedCustomPackName | ||
{ | ||
public Language language { get; set; } | ||
public string packName { get; set; } = string.Empty; | ||
} | ||
} |
20 changes: 10 additions & 10 deletions
20
Models/LocalizedMessage.cs → ...pi.Controllers/Models/LocalizedMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using BeatTogether.Status.Api.Enums; | ||
|
||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public class LocalizedMessage | ||
{ | ||
public Language language { get; set; } | ||
public string message { get; set; } = string.Empty; | ||
} | ||
} | ||
using BeatTogether.Status.Api.Controllers.Enums; | ||
|
||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public class LocalizedMessage | ||
{ | ||
public Language language { get; set; } | ||
public string message { get; set; } = string.Empty; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Models/MasterServerQuickplayData.cs → ...llers/Models/MasterServerQuickplayData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace BeatTogether.Status.Api.Models | ||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public record MasterServerQuickplayData(QuickplaySongPacksOverride quickPlayAvailablePacksOverride); | ||
} |
4 changes: 2 additions & 2 deletions
4
Models/MasterServerStatusData.cs → ...trollers/Models/MasterServerStatusData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
Models/PredefinedPack.cs → ....Api.Controllers/Models/PredefinedPack.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public class PredefinedPack | ||
{ | ||
public int order { get; set; } | ||
public string packId { get; set; } = string.Empty; | ||
} | ||
} | ||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public class PredefinedPack | ||
{ | ||
public int order { get; set; } | ||
public string packId { get; set; } = string.Empty; | ||
} | ||
} |
8 changes: 2 additions & 6 deletions
8
Models/QuickplaySongPacksOverride.cs → ...lers/Models/QuickplaySongPacksOverride.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 17 additions & 17 deletions
34
Models/RequiredMod.cs → ...tus.Api.Controllers/Models/RequiredMod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
namespace BeatTogether.Status.Api.Models | ||
{ | ||
public record RequiredMod | ||
{ | ||
/// <summary> | ||
/// BSIPA Mod ID | ||
/// </summary> | ||
public string id { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Minimum version of the mod required, if installed | ||
/// </summary> | ||
public string version { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Indicates whether the mod must be installed | ||
/// </summary> | ||
public bool required { get; set; } = false; | ||
} | ||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public record RequiredMod | ||
{ | ||
/// <summary> | ||
/// BSIPA Mod ID | ||
/// </summary> | ||
public string id { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Minimum version of the mod required, if installed | ||
/// </summary> | ||
public string version { get; set; } = string.Empty; | ||
/// <summary> | ||
/// Indicates whether the mod must be installed | ||
/// </summary> | ||
public bool required { get; set; } = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
| ||
namespace BeatTogether.Status.Api.Controllers.Models | ||
{ | ||
public record UserMessage(List<LocalizedMessage> localizedMessages); | ||
} |
File renamed without changes.
Oops, something went wrong.