mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge pull request #11271 from peppy/dev-server
Prefer connecting to dev server when running in DEBUG
This commit is contained in:
@ -26,12 +26,12 @@ namespace osu.Game.Online.API
|
||||
|
||||
private readonly OAuth authentication;
|
||||
|
||||
public string Endpoint => @"https://osu.ppy.sh";
|
||||
private const string client_id = @"5";
|
||||
private const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
|
||||
|
||||
private readonly Queue<APIRequest> queue = new Queue<APIRequest>();
|
||||
|
||||
public string APIEndpointUrl { get; }
|
||||
|
||||
public string WebsiteRootUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The username/email provided by the user when initiating a login.
|
||||
/// </summary>
|
||||
@ -55,11 +55,14 @@ namespace osu.Game.Online.API
|
||||
|
||||
private readonly Logger log;
|
||||
|
||||
public APIAccess(OsuConfigManager config)
|
||||
public APIAccess(OsuConfigManager config, EndpointConfiguration endpointConfiguration)
|
||||
{
|
||||
this.config = config;
|
||||
|
||||
authentication = new OAuth(client_id, client_secret, Endpoint);
|
||||
APIEndpointUrl = endpointConfiguration.APIEndpointUrl;
|
||||
WebsiteRootUrl = endpointConfiguration.WebsiteRootUrl;
|
||||
|
||||
authentication = new OAuth(endpointConfiguration.APIClientID, endpointConfiguration.APIClientSecret, APIEndpointUrl);
|
||||
log = Logger.GetLogger(LoggingTarget.Network);
|
||||
|
||||
ProvidedUsername = config.Get<string>(OsuSetting.Username);
|
||||
@ -245,7 +248,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
var req = new RegistrationRequest
|
||||
{
|
||||
Url = $@"{Endpoint}/users",
|
||||
Url = $@"{APIEndpointUrl}/users",
|
||||
Method = HttpMethod.Post,
|
||||
Username = username,
|
||||
Email = email,
|
||||
|
@ -57,7 +57,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
protected virtual WebRequest CreateWebRequest() => new OsuWebRequest(Uri);
|
||||
|
||||
protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}";
|
||||
protected virtual string Uri => $@"{API.APIEndpointUrl}/api/v2/{Target}";
|
||||
|
||||
protected APIAccess API;
|
||||
protected WebRequest WebRequest;
|
||||
|
@ -28,7 +28,9 @@ namespace osu.Game.Online.API
|
||||
|
||||
public string ProvidedUsername => LocalUser.Value.Username;
|
||||
|
||||
public string Endpoint => "http://localhost";
|
||||
public string APIEndpointUrl => "http://localhost";
|
||||
|
||||
public string WebsiteRootUrl => "http://localhost";
|
||||
|
||||
/// <summary>
|
||||
/// Provide handling logic for an arbitrary API request.
|
||||
|
@ -46,7 +46,12 @@ namespace osu.Game.Online.API
|
||||
/// <summary>
|
||||
/// The URL endpoint for this API. Does not include a trailing slash.
|
||||
/// </summary>
|
||||
string Endpoint { get; }
|
||||
string APIEndpointUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The root URL of of the website, excluding the trailing slash.
|
||||
/// </summary>
|
||||
string WebsiteRootUrl { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The current connection state of the API.
|
||||
|
@ -48,6 +48,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
public enum ChangelogEntryType
|
||||
{
|
||||
Add,
|
||||
Fix
|
||||
Fix,
|
||||
Misc
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ namespace osu.Game.Online.Chat
|
||||
break;
|
||||
}
|
||||
|
||||
var beatmapString = beatmap.OnlineBeatmapID.HasValue ? $"[https://osu.ppy.sh/b/{beatmap.OnlineBeatmapID} {beatmap}]" : beatmap.ToString();
|
||||
var beatmapString = beatmap.OnlineBeatmapID.HasValue ? $"[{api.WebsiteRootUrl}/b/{beatmap.OnlineBeatmapID} {beatmap}]" : beatmap.ToString();
|
||||
|
||||
channelManager.PostMessage($"is {verb} {beatmapString}", true);
|
||||
Expire();
|
||||
|
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()
|
||||
{
|
||||
WebsiteRootUrl = APIEndpointUrl = @"https://dev.ppy.sh";
|
||||
APIClientSecret = @"3LP2mhUrV89xxzD1YKNndXHEhWWCRLPNKioZ9ymT";
|
||||
APIClientID = "5";
|
||||
SpectatorEndpointUrl = $"{APIEndpointUrl}/spectator";
|
||||
MultiplayerEndpointUrl = $"{APIEndpointUrl}/multiplayer";
|
||||
}
|
||||
}
|
||||
}
|
41
osu.Game/Online/EndpointConfiguration.cs
Normal file
41
osu.Game/Online/EndpointConfiguration.cs
Normal file
@ -0,0 +1,41 @@
|
||||
// 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 base URL for the website.
|
||||
/// </summary>
|
||||
public string WebsiteRootUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The endpoint for the main (osu-web) API.
|
||||
/// </summary>
|
||||
public string APIEndpointUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The OAuth client secret.
|
||||
/// </summary>
|
||||
public string APIClientSecret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The OAuth client ID.
|
||||
/// </summary>
|
||||
public string APIClientID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The endpoint for the SignalR spectator server.
|
||||
/// </summary>
|
||||
public string SpectatorEndpointUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The endpoint for the SignalR multiplayer server.
|
||||
/// </summary>
|
||||
public string MultiplayerEndpointUrl { 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()
|
||||
{
|
||||
WebsiteRootUrl = APIEndpointUrl = @"https://osu.ppy.sh";
|
||||
APIClientSecret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
|
||||
APIClientID = "5";
|
||||
SpectatorEndpointUrl = "https://spectator.ppy.sh/spectator";
|
||||
MultiplayerEndpointUrl = "https://spectator.ppy.sh/multiplayer";
|
||||
}
|
||||
}
|
||||
}
|
@ -19,8 +19,6 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
{
|
||||
public class RealtimeMultiplayerClient : StatefulMultiplayerClient
|
||||
{
|
||||
private const string endpoint = "https://spectator.ppy.sh/multiplayer";
|
||||
|
||||
public override IBindable<bool> IsConnected => isConnected;
|
||||
|
||||
private readonly Bindable<bool> isConnected = new Bindable<bool>();
|
||||
@ -31,6 +29,13 @@ namespace osu.Game.Online.RealtimeMultiplayer
|
||||
|
||||
private HubConnection? connection;
|
||||
|
||||
private readonly string endpoint;
|
||||
|
||||
public RealtimeMultiplayerClient(EndpointConfiguration endpoints)
|
||||
{
|
||||
endpoint = endpoints.MultiplayerEndpointUrl;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
|
@ -81,6 +81,13 @@ namespace osu.Game.Online.Spectator
|
||||
/// </summary>
|
||||
public event Action<int, SpectatorState> OnUserFinishedPlaying;
|
||||
|
||||
private readonly string endpoint;
|
||||
|
||||
public SpectatorStreamingClient(EndpointConfiguration endpoints)
|
||||
{
|
||||
endpoint = endpoints.SpectatorEndpointUrl;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -104,8 +111,6 @@ namespace osu.Game.Online.Spectator
|
||||
}
|
||||
}
|
||||
|
||||
private const string endpoint = "https://spectator.ppy.sh/spectator";
|
||||
|
||||
protected virtual async Task Connect()
|
||||
{
|
||||
if (connection != null)
|
||||
|
Reference in New Issue
Block a user