mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Move all endpoint information to a configuration class
This commit is contained in:
@ -13,6 +13,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Online;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Replays.Legacy;
|
using osu.Game.Replays.Legacy;
|
||||||
using osu.Game.Rulesets.Osu.Scoring;
|
using osu.Game.Rulesets.Osu.Scoring;
|
||||||
@ -87,6 +88,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
private readonly int totalUsers;
|
private readonly int totalUsers;
|
||||||
|
|
||||||
public TestMultiplayerStreaming(int totalUsers)
|
public TestMultiplayerStreaming(int totalUsers)
|
||||||
|
: base(new DevelopmentEndpointConfiguration())
|
||||||
{
|
{
|
||||||
this.totalUsers = totalUsers;
|
this.totalUsers = totalUsers;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using osu.Framework.Screens;
|
|||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Online;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Replays.Legacy;
|
using osu.Game.Replays.Legacy;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
@ -238,6 +239,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private int beatmapId;
|
private int beatmapId;
|
||||||
|
|
||||||
|
public TestSpectatorStreamingClient()
|
||||||
|
: base(new DevelopmentEndpointConfiguration())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected override Task Connect()
|
protected override Task Connect()
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
19
osu.Game/Configuration/DevelopmentOsuConfigManager.cs
Normal file
19
osu.Game/Configuration/DevelopmentOsuConfigManager.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Platform;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
|
||||||
|
namespace osu.Game.Configuration
|
||||||
|
{
|
||||||
|
[ExcludeFromDynamicCompile]
|
||||||
|
public class DevelopmentOsuConfigManager : OsuConfigManager
|
||||||
|
{
|
||||||
|
protected override string Filename => base.Filename.Replace(".ini", ".dev.ini");
|
||||||
|
|
||||||
|
public DevelopmentOsuConfigManager(Storage storage)
|
||||||
|
: base(storage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,18 +26,10 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
private readonly OAuth authentication;
|
private readonly OAuth authentication;
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
public string Endpoint => @"https://dev.ppy.sh";
|
|
||||||
private const string client_secret = @"3LP2mhUrV89xxzD1YKNndXHEhWWCRLPNKioZ9ymT";
|
|
||||||
#else
|
|
||||||
public string Endpoint => @"https://osu.ppy.sh";
|
|
||||||
private const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private const string client_id = @"5";
|
|
||||||
|
|
||||||
private readonly Queue<APIRequest> queue = new Queue<APIRequest>();
|
private readonly Queue<APIRequest> queue = new Queue<APIRequest>();
|
||||||
|
|
||||||
|
public string Endpoint { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The username/email provided by the user when initiating a login.
|
/// The username/email provided by the user when initiating a login.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -61,11 +53,13 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
private readonly Logger log;
|
private readonly Logger log;
|
||||||
|
|
||||||
public APIAccess(OsuConfigManager config)
|
public APIAccess(OsuConfigManager config, EndpointConfiguration endpointConfiguration)
|
||||||
{
|
{
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
authentication = new OAuth(client_id, client_secret, Endpoint);
|
Endpoint = endpointConfiguration.APIEndpoint;
|
||||||
|
|
||||||
|
authentication = new OAuth(endpointConfiguration.APIClientID, endpointConfiguration.APIClientSecret, Endpoint);
|
||||||
log = Logger.GetLogger(LoggingTarget.Network);
|
log = Logger.GetLogger(LoggingTarget.Network);
|
||||||
|
|
||||||
ProvidedUsername = config.Get<string>(OsuSetting.Username);
|
ProvidedUsername = config.Get<string>(OsuSetting.Username);
|
||||||
|
17
osu.Game/Online/DevelopmentEndpointConfiguration.cs
Normal file
17
osu.Game/Online/DevelopmentEndpointConfiguration.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
namespace osu.Game.Online
|
||||||
|
{
|
||||||
|
public class DevelopmentEndpointConfiguration : EndpointConfiguration
|
||||||
|
{
|
||||||
|
public DevelopmentEndpointConfiguration()
|
||||||
|
{
|
||||||
|
APIEndpoint = @"https://dev.ppy.sh";
|
||||||
|
APIClientSecret = @"3LP2mhUrV89xxzD1YKNndXHEhWWCRLPNKioZ9ymT";
|
||||||
|
APIClientID = "5";
|
||||||
|
SpectatorEndpoint = $"{APIEndpoint}/spectator";
|
||||||
|
MultiplayerEndpoint = $"{APIEndpoint}/multiplayer";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
osu.Game/Online/EndpointConfiguration.cs
Normal file
30
osu.Game/Online/EndpointConfiguration.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
namespace osu.Game.Online
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Holds configuration for API endpoints.
|
||||||
|
/// </summary>
|
||||||
|
public class EndpointConfiguration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The endpoint for the main (osu-web) API.
|
||||||
|
/// </summary>
|
||||||
|
public string APIEndpoint { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The OAuth client secret.
|
||||||
|
/// </summary>
|
||||||
|
public string APIClientSecret { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The OAuth client ID.
|
||||||
|
/// </summary>
|
||||||
|
public string APIClientID { get; set; }
|
||||||
|
|
||||||
|
public string SpectatorEndpoint { get; set; }
|
||||||
|
|
||||||
|
public string MultiplayerEndpoint { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
osu.Game/Online/ProductionEndpointConfiguration.cs
Normal file
17
osu.Game/Online/ProductionEndpointConfiguration.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
namespace osu.Game.Online
|
||||||
|
{
|
||||||
|
public class ProductionEndpointConfiguration : EndpointConfiguration
|
||||||
|
{
|
||||||
|
public ProductionEndpointConfiguration()
|
||||||
|
{
|
||||||
|
APIEndpoint = @"https://osu.ppy.sh";
|
||||||
|
APIClientSecret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
|
||||||
|
APIClientID = "5";
|
||||||
|
SpectatorEndpoint = "https://spectator.ppy.sh/spectator";
|
||||||
|
MultiplayerEndpoint = "https://spectator.ppy.sh/multiplayer";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,12 +19,6 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
{
|
{
|
||||||
public class RealtimeMultiplayerClient : StatefulMultiplayerClient
|
public class RealtimeMultiplayerClient : StatefulMultiplayerClient
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
private const string endpoint = "https://dev.ppy.sh/multiplayer";
|
|
||||||
#else
|
|
||||||
private const string endpoint = "https://spectator.ppy.sh/multiplayer";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public override IBindable<bool> IsConnected => isConnected;
|
public override IBindable<bool> IsConnected => isConnected;
|
||||||
|
|
||||||
private readonly Bindable<bool> isConnected = new Bindable<bool>();
|
private readonly Bindable<bool> isConnected = new Bindable<bool>();
|
||||||
@ -35,6 +29,13 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
|||||||
|
|
||||||
private HubConnection? connection;
|
private HubConnection? connection;
|
||||||
|
|
||||||
|
private readonly string endpoint;
|
||||||
|
|
||||||
|
public RealtimeMultiplayerClient(EndpointConfiguration endpoints)
|
||||||
|
{
|
||||||
|
endpoint = endpoints.MultiplayerEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
@ -81,6 +81,13 @@ namespace osu.Game.Online.Spectator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<int, SpectatorState> OnUserFinishedPlaying;
|
public event Action<int, SpectatorState> OnUserFinishedPlaying;
|
||||||
|
|
||||||
|
private readonly string endpoint;
|
||||||
|
|
||||||
|
public SpectatorStreamingClient(EndpointConfiguration endpoints)
|
||||||
|
{
|
||||||
|
endpoint = endpoints.SpectatorEndpoint;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -104,12 +111,6 @@ namespace osu.Game.Online.Spectator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
private const string endpoint = "https://dev.ppy.sh/spectator";
|
|
||||||
#else
|
|
||||||
private const string endpoint = "https://spectator.ppy.sh/spectator";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected virtual async Task Connect()
|
protected virtual async Task Connect()
|
||||||
{
|
{
|
||||||
if (connection != null)
|
if (connection != null)
|
||||||
|
@ -30,6 +30,7 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Input;
|
using osu.Game.Input;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
|
using osu.Game.Online;
|
||||||
using osu.Game.Online.RealtimeMultiplayer;
|
using osu.Game.Online.RealtimeMultiplayer;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -54,6 +55,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
public const int SAMPLE_CONCURRENCY = 6;
|
public const int SAMPLE_CONCURRENCY = 6;
|
||||||
|
|
||||||
|
public bool UseDevelopmentServer { get; }
|
||||||
|
|
||||||
protected OsuConfigManager LocalConfig;
|
protected OsuConfigManager LocalConfig;
|
||||||
|
|
||||||
protected BeatmapManager BeatmapManager;
|
protected BeatmapManager BeatmapManager;
|
||||||
@ -132,6 +135,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
public OsuGameBase()
|
public OsuGameBase()
|
||||||
{
|
{
|
||||||
|
UseDevelopmentServer = DebugUtils.IsDebugBuild;
|
||||||
Name = @"osu!lazer";
|
Name = @"osu!lazer";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +174,7 @@ namespace osu.Game
|
|||||||
dependencies.Cache(largeStore);
|
dependencies.Cache(largeStore);
|
||||||
|
|
||||||
dependencies.CacheAs(this);
|
dependencies.CacheAs(this);
|
||||||
dependencies.Cache(LocalConfig);
|
dependencies.CacheAs(LocalConfig);
|
||||||
|
|
||||||
AddFont(Resources, @"Fonts/osuFont");
|
AddFont(Resources, @"Fonts/osuFont");
|
||||||
|
|
||||||
@ -210,10 +214,12 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dependencies.CacheAs(API ??= new APIAccess(LocalConfig));
|
EndpointConfiguration endpoints = UseDevelopmentServer ? (EndpointConfiguration)new DevelopmentEndpointConfiguration() : new ProductionEndpointConfiguration();
|
||||||
|
|
||||||
dependencies.CacheAs(spectatorStreaming = new SpectatorStreamingClient());
|
dependencies.CacheAs(API ??= new APIAccess(LocalConfig, endpoints));
|
||||||
dependencies.CacheAs(multiplayerClient = new RealtimeMultiplayerClient());
|
|
||||||
|
dependencies.CacheAs(spectatorStreaming = new SpectatorStreamingClient(endpoints));
|
||||||
|
dependencies.CacheAs(multiplayerClient = new RealtimeMultiplayerClient(endpoints));
|
||||||
|
|
||||||
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
|
||||||
|
|
||||||
@ -369,7 +375,9 @@ namespace osu.Game
|
|||||||
// may be non-null for certain tests
|
// may be non-null for certain tests
|
||||||
Storage ??= host.Storage;
|
Storage ??= host.Storage;
|
||||||
|
|
||||||
LocalConfig ??= new OsuConfigManager(Storage);
|
LocalConfig ??= UseDevelopmentServer
|
||||||
|
? new DevelopmentOsuConfigManager(Storage)
|
||||||
|
: new OsuConfigManager(Storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Storage CreateStorage(GameHost host, Storage defaultStorage) => new OsuStorage(host, defaultStorage);
|
protected override Storage CreateStorage(GameHost host, Storage defaultStorage) => new OsuStorage(host, defaultStorage);
|
||||||
|
Reference in New Issue
Block a user