mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
Merge pull request #11615 from peppy/ios-signalr-use-json
This commit is contained in:
commit
1d76cfe585
@ -9,6 +9,8 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.SignalR.Client;
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -64,13 +66,19 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
if (connection != null)
|
if (connection != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
connection = new HubConnectionBuilder()
|
var builder = new HubConnectionBuilder()
|
||||||
.WithUrl(endpoint, options =>
|
.WithUrl(endpoint, options => { options.Headers.Add("Authorization", $"Bearer {api.AccessToken}"); });
|
||||||
|
|
||||||
|
if (RuntimeInfo.SupportsJIT)
|
||||||
|
builder.AddMessagePackProtocol();
|
||||||
|
else
|
||||||
{
|
{
|
||||||
options.Headers.Add("Authorization", $"Bearer {api.AccessToken}");
|
// eventually we will precompile resolvers for messagepack, but this isn't working currently
|
||||||
})
|
// see https://github.com/neuecc/MessagePack-CSharp/issues/780#issuecomment-768794308.
|
||||||
.AddMessagePackProtocol()
|
builder.AddNewtonsoftJsonProtocol(options => { options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; });
|
||||||
.Build();
|
}
|
||||||
|
|
||||||
|
connection = builder.Build();
|
||||||
|
|
||||||
// this is kind of SILLY
|
// this is kind of SILLY
|
||||||
// https://github.com/dotnet/aspnetcore/issues/15198
|
// https://github.com/dotnet/aspnetcore/issues/15198
|
||||||
|
@ -9,6 +9,8 @@ using System.Threading.Tasks;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.AspNetCore.SignalR.Client;
|
using Microsoft.AspNetCore.SignalR.Client;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -115,14 +117,19 @@ namespace osu.Game.Online.Spectator
|
|||||||
if (connection != null)
|
if (connection != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
connection = new HubConnectionBuilder()
|
var builder = new HubConnectionBuilder()
|
||||||
.WithUrl(endpoint, options =>
|
.WithUrl(endpoint, options => { options.Headers.Add("Authorization", $"Bearer {api.AccessToken}"); });
|
||||||
{
|
|
||||||
options.Headers.Add("Authorization", $"Bearer {api.AccessToken}");
|
|
||||||
})
|
|
||||||
.AddMessagePackProtocol()
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
|
if (RuntimeInfo.SupportsJIT)
|
||||||
|
builder.AddMessagePackProtocol();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// eventually we will precompile resolvers for messagepack, but this isn't working currently
|
||||||
|
// see https://github.com/neuecc/MessagePack-CSharp/issues/780#issuecomment-768794308.
|
||||||
|
builder.AddNewtonsoftJsonProtocol(options => { options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; });
|
||||||
|
}
|
||||||
|
|
||||||
|
connection = builder.Build();
|
||||||
// until strong typed client support is added, each method must be manually bound (see https://github.com/dotnet/aspnetcore/issues/15198)
|
// until strong typed client support is added, each method must be manually bound (see https://github.com/dotnet/aspnetcore/issues/15198)
|
||||||
connection.On<int, SpectatorState>(nameof(ISpectatorClient.UserBeganPlaying), ((ISpectatorClient)this).UserBeganPlaying);
|
connection.On<int, SpectatorState>(nameof(ISpectatorClient.UserBeganPlaying), ((ISpectatorClient)this).UserBeganPlaying);
|
||||||
connection.On<int, FrameDataBundle>(nameof(ISpectatorClient.UserSentFrames), ((ISpectatorClient)this).UserSentFrames);
|
connection.On<int, FrameDataBundle>(nameof(ISpectatorClient.UserSentFrames), ((ISpectatorClient)this).UserSentFrames);
|
||||||
|
Loading…
Reference in New Issue
Block a user