mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2025-03-03 16:45:00 +01:00
misc: chore: Move the LDN constants into a SharedConstants class
This commit is contained in:
parent
c47448628c
commit
6c6580ddcc
9
src/Ryujinx.Common/SharedConstants.cs
Normal file
9
src/Ryujinx.Common/SharedConstants.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Ryujinx.Common
|
||||||
|
{
|
||||||
|
public static class SharedConstants
|
||||||
|
{
|
||||||
|
public const string DefaultLanPlayHost = "ryuldn.vudjun.com";
|
||||||
|
public const short LanPlayPort = 30456;
|
||||||
|
public const string DefaultLanPlayWebHost = "ryuldnweb.vudjun.com";
|
||||||
|
}
|
||||||
|
}
|
@ -23,9 +23,6 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
|||||||
{
|
{
|
||||||
class IUserLocalCommunicationService : IpcService, IDisposable
|
class IUserLocalCommunicationService : IpcService, IDisposable
|
||||||
{
|
{
|
||||||
public static string DefaultLanPlayHost = "ryuldn.vudjun.com";
|
|
||||||
public static short LanPlayPort = 30456;
|
|
||||||
|
|
||||||
public INetworkClient NetworkClient { get; private set; }
|
public INetworkClient NetworkClient { get; private set; }
|
||||||
|
|
||||||
private const int NifmRequestID = 90;
|
private const int NifmRequestID = 90;
|
||||||
@ -1092,20 +1089,18 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
|||||||
case MultiplayerMode.LdnRyu:
|
case MultiplayerMode.LdnRyu:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string ldnServer = context.Device.Configuration.MultiplayerLdnServer;
|
string ldnServer = context.Device.Configuration.MultiplayerLdnServer
|
||||||
if (string.IsNullOrEmpty(ldnServer))
|
?? throw new InvalidOperationException("Cannot initialize RyuLDN with a null Multiplayer server.");
|
||||||
{
|
|
||||||
ldnServer = DefaultLanPlayHost;
|
|
||||||
}
|
|
||||||
if (!IPAddress.TryParse(ldnServer, out IPAddress ipAddress))
|
if (!IPAddress.TryParse(ldnServer, out IPAddress ipAddress))
|
||||||
{
|
{
|
||||||
ipAddress = Dns.GetHostEntry(ldnServer).AddressList[0];
|
ipAddress = Dns.GetHostEntry(ldnServer).AddressList[0];
|
||||||
}
|
}
|
||||||
NetworkClient = new LdnMasterProxyClient(ipAddress.ToString(), LanPlayPort, context.Device.Configuration);
|
NetworkClient = new LdnMasterProxyClient(ipAddress.ToString(), SharedConstants.LanPlayPort, context.Device.Configuration);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error?.Print(LogClass.ServiceLdn, "Could not locate LdnRyu server. Defaulting to stubbed wireless.");
|
Logger.Error?.Print(LogClass.ServiceLdn, "Could not locate RyuLDN server. Defaulting to stubbed wireless.");
|
||||||
Logger.Error?.Print(LogClass.ServiceLdn, ex.Message);
|
Logger.Error?.Print(LogClass.ServiceLdn, ex.Message);
|
||||||
NetworkClient = new LdnDisabledClient();
|
NetworkClient = new LdnDisabledClient();
|
||||||
}
|
}
|
||||||
|
@ -951,7 +951,7 @@ namespace Ryujinx.Ava
|
|||||||
ConfigurationState.Instance.Multiplayer.Mode,
|
ConfigurationState.Instance.Multiplayer.Mode,
|
||||||
ConfigurationState.Instance.Multiplayer.DisableP2p,
|
ConfigurationState.Instance.Multiplayer.DisableP2p,
|
||||||
ConfigurationState.Instance.Multiplayer.LdnPassphrase,
|
ConfigurationState.Instance.Multiplayer.LdnPassphrase,
|
||||||
ConfigurationState.Instance.Multiplayer.LdnServer,
|
ConfigurationState.Instance.Multiplayer.GetLdnServer(),
|
||||||
ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value,
|
ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value,
|
||||||
ConfigurationState.Instance.Hacks.ShowDirtyHacks ? ConfigurationState.Instance.Hacks.EnabledHacks : null));
|
ConfigurationState.Instance.Hacks.ShowDirtyHacks ? ConfigurationState.Instance.Hacks.EnabledHacks : null));
|
||||||
}
|
}
|
||||||
|
@ -24073,4 +24073,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -42,7 +42,6 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
|
|||||||
{
|
{
|
||||||
public class ApplicationLibrary
|
public class ApplicationLibrary
|
||||||
{
|
{
|
||||||
public const string DefaultLanPlayWebHost = "ryuldnweb.vudjun.com";
|
|
||||||
public Language DesiredLanguage { get; set; }
|
public Language DesiredLanguage { get; set; }
|
||||||
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
|
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
|
||||||
public event Action<LdnGameDataReceivedEventArgs> LdnGameDataReceived;
|
public event Action<LdnGameDataReceivedEventArgs> LdnGameDataReceived;
|
||||||
@ -826,7 +825,6 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
|
|||||||
|
|
||||||
public async Task RefreshLdn()
|
public async Task RefreshLdn()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ConfigurationState.Instance.Multiplayer.Mode == MultiplayerMode.LdnRyu)
|
if (ConfigurationState.Instance.Multiplayer.Mode == MultiplayerMode.LdnRyu)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -834,33 +832,22 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
|
|||||||
string ldnWebHost = ConfigurationState.Instance.Multiplayer.LdnServer;
|
string ldnWebHost = ConfigurationState.Instance.Multiplayer.LdnServer;
|
||||||
if (string.IsNullOrEmpty(ldnWebHost))
|
if (string.IsNullOrEmpty(ldnWebHost))
|
||||||
{
|
{
|
||||||
ldnWebHost = DefaultLanPlayWebHost;
|
ldnWebHost = SharedConstants.DefaultLanPlayWebHost;
|
||||||
}
|
}
|
||||||
IEnumerable<LdnGameData> ldnGameDataArray = Array.Empty<LdnGameData>();
|
|
||||||
using HttpClient httpClient = new();
|
using HttpClient httpClient = new();
|
||||||
string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games");
|
string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games");
|
||||||
ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData);
|
LdnGameData[] ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData).ToArray();
|
||||||
LdnGameDataReceived?.Invoke(new LdnGameDataReceivedEventArgs
|
LdnGameDataReceived?.Invoke(new LdnGameDataReceivedEventArgs(ldnGameDataArray));
|
||||||
{
|
return;
|
||||||
LdnData = ldnGameDataArray
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.Application, $"Failed to fetch the public games JSON from the API. Player and game count in the game list will be unavailable.\n{ex.Message}");
|
Logger.Warning?.Print(LogClass.Application, $"Failed to fetch the public games JSON from the API. Player and game count in the game list will be unavailable.\n{ex.Message}");
|
||||||
LdnGameDataReceived?.Invoke(new LdnGameDataReceivedEventArgs
|
|
||||||
{
|
|
||||||
LdnData = Array.Empty<LdnGameData>()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
LdnGameDataReceived?.Invoke(LdnGameDataReceivedEventArgs.Empty);
|
||||||
LdnGameDataReceived?.Invoke(new LdnGameDataReceivedEventArgs
|
|
||||||
{
|
|
||||||
LdnData = Array.Empty<LdnGameData>()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the currently stored DLC state for the game with the provided DLC state.
|
// Replace the currently stored DLC state for the game with the provided DLC state.
|
||||||
|
@ -5,6 +5,14 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
|
|||||||
{
|
{
|
||||||
public class LdnGameDataReceivedEventArgs : EventArgs
|
public class LdnGameDataReceivedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
public IEnumerable<LdnGameData> LdnData { get; set; }
|
public static new readonly LdnGameDataReceivedEventArgs Empty = new(null);
|
||||||
|
|
||||||
|
public LdnGameDataReceivedEventArgs(LdnGameData[] ldnData)
|
||||||
|
{
|
||||||
|
LdnData = ldnData ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LdnGameData[] LdnData { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using ARMeilleure;
|
using ARMeilleure;
|
||||||
using Gommon;
|
using Gommon;
|
||||||
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
using Ryujinx.Ava.Utilities.Configuration.System;
|
using Ryujinx.Ava.Utilities.Configuration.System;
|
||||||
using Ryujinx.Ava.Utilities.Configuration.UI;
|
using Ryujinx.Ava.Utilities.Configuration.UI;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
@ -647,6 +648,14 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<string> LdnServer { get; private set; }
|
public ReactiveObject<string> LdnServer { get; private set; }
|
||||||
|
|
||||||
|
public string GetLdnServer()
|
||||||
|
{
|
||||||
|
string ldnServer = LdnServer;
|
||||||
|
return string.IsNullOrEmpty(ldnServer)
|
||||||
|
? SharedConstants.DefaultLanPlayHost
|
||||||
|
: ldnServer;
|
||||||
|
}
|
||||||
|
|
||||||
public MultiplayerSection()
|
public MultiplayerSection()
|
||||||
{
|
{
|
||||||
LanInterfaceId = new ReactiveObject<string>();
|
LanInterfaceId = new ReactiveObject<string>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user