mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 05:22:54 +08:00
Add the ability to not use MessagePack when creating a HubConnector
This commit is contained in:
parent
1cd967b351
commit
617ff40de7
@ -257,8 +257,8 @@ namespace osu.Game.Online.API
|
|||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHubClientConnector GetHubConnector(string clientName, string endpoint) =>
|
public IHubClientConnector GetHubConnector(string clientName, string endpoint, bool preferMessagePack) =>
|
||||||
new HubClientConnector(clientName, endpoint, this, versionHash);
|
new HubClientConnector(clientName, endpoint, this, versionHash, preferMessagePack);
|
||||||
|
|
||||||
public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password)
|
public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password)
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Online.API
|
|||||||
state.Value = APIState.Offline;
|
state.Value = APIState.Offline;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IHubClientConnector GetHubConnector(string clientName, string endpoint) => null;
|
public IHubClientConnector GetHubConnector(string clientName, string endpoint, bool preferMessagePack) => null;
|
||||||
|
|
||||||
public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password)
|
public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,8 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clientName">The name of the client this connector connects for, used for logging.</param>
|
/// <param name="clientName">The name of the client this connector connects for, used for logging.</param>
|
||||||
/// <param name="endpoint">The endpoint to the hub.</param>
|
/// <param name="endpoint">The endpoint to the hub.</param>
|
||||||
IHubClientConnector? GetHubConnector(string clientName, string endpoint);
|
/// <param name="preferMessagePack"></param>
|
||||||
|
IHubClientConnector? GetHubConnector(string clientName, string endpoint, bool preferMessagePack = true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new user account. This is a blocking operation.
|
/// Create a new user account. This is a blocking operation.
|
||||||
|
@ -26,6 +26,7 @@ namespace osu.Game.Online
|
|||||||
private readonly string clientName;
|
private readonly string clientName;
|
||||||
private readonly string endpoint;
|
private readonly string endpoint;
|
||||||
private readonly string versionHash;
|
private readonly string versionHash;
|
||||||
|
private readonly bool preferMessagePack;
|
||||||
private readonly IAPIProvider api;
|
private readonly IAPIProvider api;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -51,12 +52,14 @@ namespace osu.Game.Online
|
|||||||
/// <param name="endpoint">The endpoint to the hub.</param>
|
/// <param name="endpoint">The endpoint to the hub.</param>
|
||||||
/// <param name="api"> An API provider used to react to connection state changes.</param>
|
/// <param name="api"> An API provider used to react to connection state changes.</param>
|
||||||
/// <param name="versionHash">The hash representing the current game version, used for verification purposes.</param>
|
/// <param name="versionHash">The hash representing the current game version, used for verification purposes.</param>
|
||||||
public HubClientConnector(string clientName, string endpoint, IAPIProvider api, string versionHash)
|
/// <param name="preferMessagePack">Whether to use MessagePack for serialisation if available on this platform.</param>
|
||||||
|
public HubClientConnector(string clientName, string endpoint, IAPIProvider api, string versionHash, bool preferMessagePack = true)
|
||||||
{
|
{
|
||||||
this.clientName = clientName;
|
this.clientName = clientName;
|
||||||
this.endpoint = endpoint;
|
this.endpoint = endpoint;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.versionHash = versionHash;
|
this.versionHash = versionHash;
|
||||||
|
this.preferMessagePack = preferMessagePack;
|
||||||
|
|
||||||
apiState.BindTo(api.State);
|
apiState.BindTo(api.State);
|
||||||
apiState.BindValueChanged(state =>
|
apiState.BindValueChanged(state =>
|
||||||
@ -144,7 +147,7 @@ namespace osu.Game.Online
|
|||||||
options.Headers.Add("OsuVersionHash", versionHash);
|
options.Headers.Add("OsuVersionHash", versionHash);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (RuntimeInfo.SupportsJIT)
|
if (RuntimeInfo.SupportsJIT && preferMessagePack)
|
||||||
builder.AddMessagePackProtocol();
|
builder.AddMessagePackProtocol();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,9 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IAPIProvider api)
|
private void load(IAPIProvider api)
|
||||||
{
|
{
|
||||||
connector = api.GetHubConnector(nameof(OnlineMultiplayerClient), endpoint);
|
// Importantly, we are intentionally not using MessagePack here to correctly support derived class serialization.
|
||||||
|
// More information on the limitations / reasoning can be found in osu-server-spectator's initialisation code.
|
||||||
|
connector = api.GetHubConnector(nameof(OnlineMultiplayerClient), endpoint, false);
|
||||||
|
|
||||||
if (connector != null)
|
if (connector != null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user