|
| 1 | +using MessagePack; |
1 | 2 | using Microsoft.AspNetCore.Http.Connections; |
2 | 3 | using Microsoft.Extensions.Options; |
3 | 4 | using OpenShock.API.Realtime; |
|
9 | 10 | using OpenShock.Common.DeviceControl; |
10 | 11 | using OpenShock.Common.Extensions; |
11 | 12 | using OpenShock.Common.Hubs; |
| 13 | +using OpenShock.Common.JsonSerialization; |
12 | 14 | using OpenShock.Common.Options; |
13 | 15 | using OpenShock.Common.Services; |
14 | 16 | using OpenShock.Common.Services.Device; |
|
38 | 40 |
|
39 | 41 | builder.Services.AddSignalR() |
40 | 42 | .AddOpenShockStackExchangeRedis(options => { options.Configuration = redisConfig; }) |
41 | | - .AddMessagePackProtocol(); |
| 43 | + .AddJsonProtocol(options => |
| 44 | + { |
| 45 | + options.PayloadSerializerOptions.PropertyNameCaseInsensitive = true; |
| 46 | + options.PayloadSerializerOptions.Converters.Add(new SemVersionJsonConverter()); |
| 47 | + }) |
| 48 | + .AddMessagePackProtocol(options => |
| 49 | + { |
| 50 | + options.SerializerOptions = MessagePackSerializerOptions.Standard.WithResolver( |
| 51 | + MessagePack.Resolvers.CompositeResolver.Create( |
| 52 | + MessagePack.Resolvers.NativeGuidResolver.Instance, |
| 53 | + MessagePack.Resolvers.StandardResolver.Instance |
| 54 | + )) |
| 55 | + .WithSecurity(MessagePackSecurity.UntrustedData); |
| 56 | + }); |
42 | 57 |
|
43 | 58 | builder.Services.AddScoped<IDeviceService, DeviceService>(); |
44 | 59 | builder.Services.AddScoped<IControlSender, ControlSender>(); |
|
0 commit comments