AyCode.Core/AyCode.Services/SignalRs
Loretta 0cb2b6c2d8 SignalR: Add streaming & zero-copy binary protocol
- Introduce OnReceiveStreamMessage for server/client streaming via IAsyncEnumerable<byte[]>
- AcBinaryHubProtocol: switch argument framing to INT32, enable direct zero-copy serialization to SignalR pipe
- Optimize byte[] argument handling (fast-path, no extra alloc)
- BufferWriterBinaryOutput: support configurable chunk size, add FlushAndReset
- AcBinarySerializer: IBufferWriter overload returns bytes written
- Update docs for streaming, protocol, and performance guidance
- Minor refactoring, add InternalsVisibleTo, improve comments
2026-04-04 00:47:48 +02:00
..
AcBinaryHubProtocol.cs SignalR: Add streaming & zero-copy binary protocol 2026-04-04 00:47:48 +02:00
AcSignalRClientBase.cs SignalR: Add streaming & zero-copy binary protocol 2026-04-04 00:47:48 +02:00
AcSignalRTags.cs Refactor JSON/SignalR infra; add full test & benchmark suite 2025-12-11 21:25:50 +01:00
IAcSignalRHubBase.cs SignalR: Add streaming & zero-copy binary protocol 2026-04-04 00:47:48 +02:00
IAcSignalRHubClient.cs Switch to binary serialization; add IEntityComment interface 2026-03-06 14:51:06 +01:00
README.md SignalR: Add streaming & zero-copy binary protocol 2026-04-04 00:47:48 +02:00
SendToClientType.cs SignalR improvements; 2025-10-30 14:55:47 +01:00
SignalMessageTagAttribute.cs SignalR improvements; 2025-10-30 14:55:47 +01:00
SignalRCrudTags.cs improvements, fixes 2024-06-09 11:13:23 +02:00
SignalRRequestModel.cs Fix binary deserializer string interning and add regressions 2025-12-13 00:12:21 +01:00
SignalRSerializationHelper.cs Refactor serializer options, string fast paths & analysis 2026-01-25 16:40:40 +01:00

README.md

SignalRs

Custom binary SignalR protocol, client infrastructure, message tagging, and serialization helpers.

Architecture: For full dispatch flow, tag system, and tech debt documentation see AyCode.Services/docs/SIGNALR.md.

Key Files

Protocol

  • AcBinaryHubProtocol.cs — Custom IHubProtocol replacing JSON+Base64 with AcBinarySerializer. Handles all 9 SignalR message types (Invocation, StreamItem, Completion, Ping, Close, etc.). Uses BufferWriterBinaryOutput standalone mode for zero-copy writes to the SignalR pipe. byte[] fast-path bypasses the serializer entirely. Inner SpanReader ref struct for zero-alloc parsing.

Client

  • AcSignalRClientBase.cs — Abstract SignalR client managing HubConnection, request/response tracking via pooled SignalRRequestModel. Methods: SendMessageToServerAsync<TResponse>(), CRUD helpers (Post, Get, GetAll, GetAllInto). Configurable timeouts.
  • IAcSignalRHubClient.cs — Client interface + SignalResponseDataMessage (sealed, supports JSON/Binary with GZip, caching, diagnostics).
  • IAcSignalRHubBase.cs — Base hub interface: OnReceiveMessage(int messageTag, byte[] messageBytes, int? requestId).

Message Tagging

  • SignalMessageTagAttribute.cs — Three attributes: TagAttribute (base, int messageTag), SignalRAttribute (server method routing + client notification), SignalRSendToClientAttribute (client-side receive).
  • AcSignalRTags.cs — Static constants: None, PingTag, EchoTag.
  • SignalRCrudTags.cs — Sealed class bundling 5 independent CRUD tag integers. GetMessageTagByTrackingState() maps TrackingState → tag. See AyCode.Services.Server/docs/SIGNALR_DATASOURCE.md.
  • SendToClientType.cs — Enum: None, Others, Caller, All.

Serialization & Pooling

  • SignalRSerializationHelper.cs — Static helpers: SerializeToBinary(), DeserializeFromBinary(), compressed JSON variants, CreateResponseData().
  • SignalRRequestModel.cs — Poolable (IResettable) request tracking model with ObjectPool for reuse.