From d68f060e669df49c25d1bfd55a2e6969e943508a Mon Sep 17 00:00:00 2001 From: Loretta Date: Sat, 4 Apr 2026 23:22:53 +0200 Subject: [PATCH] Add AcBinaryHubProtocol to SignalR for binary transport Registered custom AcBinaryHubProtocol as a singleton IHubProtocol in PluginNopStartup.cs to enable efficient binary messaging (via AcBinarySerializer) and eliminate JSON/Base64 overhead. Updated SIGNALR_ENDPOINTS.md to document the new protocol, noting WebSocket (TransferFormat.Binary) requirement and affected hubs (DevAdminSignalRHub, LoggerSignalRHub). Explicitly set StatefulReconnectBufferSize to 30 MB in both code and documentation. --- Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs | 4 ++++ Nop.Plugin.Misc.AIPlugin/docs/SIGNALR_ENDPOINTS.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs b/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs index 3a93a69..214a87c 100644 --- a/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs +++ b/Nop.Plugin.Misc.AIPlugin/Infrastructure/PluginNopStartup.cs @@ -1,6 +1,7 @@ //using AyCode.Core.Loggers; using AyCode.Core.Loggers; +using AyCode.Services.SignalRs; using DevExpress.AspNetCore; using FruitBank.Common; using FruitBank.Common.Interfaces; @@ -13,6 +14,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http.Connections; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.SignalR; +using Microsoft.AspNetCore.SignalR.Protocol; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Nop.Core.Domain.Orders; @@ -149,6 +151,8 @@ public class PluginNopStartup : INopStartup hubOptions.StatefulReconnectBufferSize = 30_000_000; //30MB; //default: 100,000 bytes; //hubOptions.HandshakeTimeout = TimeSpan.FromSeconds(15); //default timeout is 15 seconds }); + + services.AddSingleton(new AcBinaryHubProtocol()); } /// diff --git a/Nop.Plugin.Misc.AIPlugin/docs/SIGNALR_ENDPOINTS.md b/Nop.Plugin.Misc.AIPlugin/docs/SIGNALR_ENDPOINTS.md index 6217ca0..2cb5dde 100644 --- a/Nop.Plugin.Misc.AIPlugin/docs/SIGNALR_ENDPOINTS.md +++ b/Nop.Plugin.Misc.AIPlugin/docs/SIGNALR_ENDPOINTS.md @@ -16,6 +16,10 @@ Configured in `PluginNopStartup`: | ClientTimeoutInterval | 30 seconds | | MaximumReceiveMessageSize | 30 MB | | EnableDetailedErrors | true | +| StatefulReconnectBufferSize | 30 MB | +| **HubProtocol** | **`AcBinaryHubProtocol`** (singleton `IHubProtocol`) | + +**Wire protocol:** `AcBinaryHubProtocol` (`AyCode.Services.SignalRs`, from `AyCode.Services.dll`) — custom binary `IHubProtocol` using `AcBinarySerializer`. Eliminates JSON+Base64 overhead. Requires `TransferFormat.Binary` → WebSocket transport only. Protocol name: `"acbinary"`. Registered as `services.AddSingleton(new AcBinaryHubProtocol())` after `AddSignalR()`. Hubs registered: `DevAdminSignalRHub`, `LoggerSignalRHub` (from AyCode.Core.Server).