mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 22:17:22 +01:00
Messagepack (#24)
* add messagepack to signalr * add resolvers to messagepack --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
This commit is contained in:
parent
ab05198aad
commit
6f9bacab5b
5 changed files with 41 additions and 1 deletions
2
MareAPI
2
MareAPI
|
|
@ -1 +1 @@
|
||||||
Subproject commit f604e6d27ebf760dd44feb53a11b8c04e91edc67
|
Subproject commit 15d1be05fa02ab22dbf75cdc7477b432f0ecaa71
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="7.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="7.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.26.0" />
|
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.26.0" />
|
||||||
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
|
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ using StackExchange.Redis.Extensions.Core.Configuration;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using StackExchange.Redis.Extensions.System.Text.Json;
|
using StackExchange.Redis.Extensions.System.Text.Json;
|
||||||
using MareSynchronos.API.SignalR;
|
using MareSynchronos.API.SignalR;
|
||||||
|
using MessagePack;
|
||||||
|
using MessagePack.Resolvers;
|
||||||
|
|
||||||
namespace MareSynchronosServer;
|
namespace MareSynchronosServer;
|
||||||
|
|
||||||
|
|
@ -102,6 +104,23 @@ public class Startup
|
||||||
hubOptions.StreamBufferCapacity = 200;
|
hubOptions.StreamBufferCapacity = 200;
|
||||||
|
|
||||||
hubOptions.AddFilter<SignalRLimitFilter>();
|
hubOptions.AddFilter<SignalRLimitFilter>();
|
||||||
|
}).AddMessagePackProtocol(opt =>
|
||||||
|
{
|
||||||
|
var resolver = CompositeResolver.Create(StandardResolverAllowPrivate.Instance,
|
||||||
|
BuiltinResolver.Instance,
|
||||||
|
AttributeFormatterResolver.Instance,
|
||||||
|
// replace enum resolver
|
||||||
|
DynamicEnumAsStringResolver.Instance,
|
||||||
|
DynamicGenericResolver.Instance,
|
||||||
|
DynamicUnionResolver.Instance,
|
||||||
|
DynamicObjectResolver.Instance,
|
||||||
|
PrimitiveObjectResolver.Instance,
|
||||||
|
// final fallback(last priority)
|
||||||
|
StandardResolver.Instance);
|
||||||
|
|
||||||
|
opt.SerializerOptions = MessagePackSerializerOptions.Standard
|
||||||
|
.WithCompression(MessagePackCompression.Lz4Block)
|
||||||
|
.WithResolver(resolver);
|
||||||
});
|
});
|
||||||
|
|
||||||
// configure redis for SignalR
|
// configure redis for SignalR
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="7.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.SignalR.StackExchangeRedis" Version="7.0.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="7.0.0" />
|
||||||
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
|
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ using MareSynchronosShared.Services;
|
||||||
using MareSynchronosShared.Utils;
|
using MareSynchronosShared.Utils;
|
||||||
using MareSynchronosStaticFilesServer.Services;
|
using MareSynchronosStaticFilesServer.Services;
|
||||||
using MareSynchronosStaticFilesServer.Utils;
|
using MareSynchronosStaticFilesServer.Utils;
|
||||||
|
using MessagePack;
|
||||||
|
using MessagePack.Resolvers;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
|
|
@ -172,6 +174,23 @@ public class Startup
|
||||||
hubOptions.EnableDetailedErrors = true;
|
hubOptions.EnableDetailedErrors = true;
|
||||||
hubOptions.MaximumParallelInvocationsPerClient = 10;
|
hubOptions.MaximumParallelInvocationsPerClient = 10;
|
||||||
hubOptions.StreamBufferCapacity = 200;
|
hubOptions.StreamBufferCapacity = 200;
|
||||||
|
}).AddMessagePackProtocol(opt =>
|
||||||
|
{
|
||||||
|
var resolver = CompositeResolver.Create(StandardResolverAllowPrivate.Instance,
|
||||||
|
BuiltinResolver.Instance,
|
||||||
|
AttributeFormatterResolver.Instance,
|
||||||
|
// replace enum resolver
|
||||||
|
DynamicEnumAsStringResolver.Instance,
|
||||||
|
DynamicGenericResolver.Instance,
|
||||||
|
DynamicUnionResolver.Instance,
|
||||||
|
DynamicObjectResolver.Instance,
|
||||||
|
PrimitiveObjectResolver.Instance,
|
||||||
|
// final fallback(last priority)
|
||||||
|
StandardResolver.Instance);
|
||||||
|
|
||||||
|
opt.SerializerOptions = MessagePackSerializerOptions.Standard
|
||||||
|
.WithCompression(MessagePackCompression.Lz4Block)
|
||||||
|
.WithResolver(resolver);
|
||||||
});
|
});
|
||||||
|
|
||||||
// configure redis for SignalR
|
// configure redis for SignalR
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue