mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-10-06 08:10:13 +00:00
Implement basic RPC configuration API endpoint (#864)
* Implement basic RPC information endpoint with test data * Implement configuration options for RPC * Rename RpcConfiguration to RpcResponse * Rider insists on modifying dataSources.xml * Implement documentation and fix code quality/gitignore issues * Use SerializableAttribute instead of UsedImplicitlyAttribute * Add warning regarding nullable assets * Prevent precision issues with application ID * Check asset properties for null/whitespace and return null
This commit is contained in:
parent
7939211308
commit
e072201ec7
7 changed files with 123 additions and 20 deletions
33
ProjectLighthouse.Servers.API/Responses/RpcResponse.cs
Normal file
33
ProjectLighthouse.Servers.API/Responses/RpcResponse.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
#nullable disable
|
||||
|
||||
using LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
||||
|
||||
public class RpcResponse
|
||||
{
|
||||
public string ApplicationId { get; set; }
|
||||
public string PartyIdPrefix { get; set; }
|
||||
public UsernameType UsernameType { get; set; }
|
||||
public RpcAssets Assets { get; set; }
|
||||
|
||||
public static RpcResponse CreateFromConfiguration(RichPresenceConfiguration configuration) =>
|
||||
new()
|
||||
{
|
||||
ApplicationId = configuration.ApplicationId,
|
||||
PartyIdPrefix = configuration.PartyIdPrefix,
|
||||
UsernameType = configuration.UsernameType,
|
||||
Assets = new RpcAssets
|
||||
{
|
||||
PodAsset = AssetConvertNull(configuration.Assets.PodAsset),
|
||||
MoonAsset = AssetConvertNull(configuration.Assets.MoonAsset),
|
||||
RemoteMoonAsset = AssetConvertNull(configuration.Assets.RemoteMoonAsset),
|
||||
DeveloperAsset = AssetConvertNull(configuration.Assets.DeveloperAsset),
|
||||
DeveloperAdventureAsset = AssetConvertNull(configuration.Assets.DeveloperAdventureAsset),
|
||||
DlcAsset = AssetConvertNull(configuration.Assets.DlcAsset),
|
||||
FallbackAsset = AssetConvertNull(configuration.Assets.FallbackAsset),
|
||||
},
|
||||
};
|
||||
|
||||
private static string AssetConvertNull(string asset) => string.IsNullOrWhiteSpace(asset) ? null : asset;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue