AyCode.Core/AyCode.Services/SignalRs
Loretta d147398698 Switch SignalR payloads to ArrayPool-backed SignalData
Major protocol refactor: all byte[] payloads in SignalR hub/client interfaces, plumbing, and DTOs are now wrapped in SignalData, a disposable, ArrayPool-backed type with Span access. Introduces AyCodeBinaryHubProtocol (derived from AcBinaryHubProtocol) to rent pooled buffers for SignalData on receive. All message signatures, diagnostics, and serialization logic updated. Documentation and tests revised to reflect SignalData usage. Enables zero-copy, low-GC, high-performance binary messaging for large payloads.
2026-04-06 11:17:02 +02:00
..
AcBinaryHubProtocol.cs Switch SignalR payloads to ArrayPool-backed SignalData 2026-04-06 11:17:02 +02:00
AcSignalRClientBase.cs Switch SignalR payloads to ArrayPool-backed SignalData 2026-04-06 11:17:02 +02:00
AcSignalRTags.cs Refactor JSON/SignalR infra; add full test & benchmark suite 2025-12-11 21:25:50 +01:00
AyCodeBinaryHubProtocol.cs Switch SignalR payloads to ArrayPool-backed SignalData 2026-04-06 11:17:02 +02:00
IAcSignalRHubBase.cs Switch SignalR payloads to ArrayPool-backed SignalData 2026-04-06 11:17:02 +02:00
IAcSignalRHubClient.cs Switch SignalR payloads to ArrayPool-backed SignalData 2026-04-06 11:17:02 +02:00
ISignalParams.cs Refactor SignalR param handling: SignalParams replaces old 2026-04-06 08:49:12 +02:00
README.md Switch SignalR payloads to ArrayPool-backed SignalData 2026-04-06 11:17:02 +02:00
SendToClientType.cs SignalR improvements; 2025-10-30 14:55:47 +01:00
SignalData.cs Switch SignalR payloads to ArrayPool-backed SignalData 2026-04-06 11:17:02 +02: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 SignalR param handling: SignalParams replaces old 2026-04-06 08:49:12 +02: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. Binary protocol: For wire format, zero-copy pipeline, and dual BWO pattern see AyCode.Services/docs/SIGNALR_BINARY_PROTOCOL.md.

Key Files

Protocol

  • AcBinaryHubProtocol.cs — Unsealed base IHubProtocol replacing JSON+Base64 with AcBinarySerializer. Handles all 9 SignalR message types. Uses BufferWriterBinaryOutput standalone mode for zero-copy writes. byte[]/SignalData fast-path bypasses serializer. CreateByteArrayResult virtual hook for derived protocols. Inner SpanReader ref struct for zero-alloc parsing.
  • AyCodeBinaryHubProtocol.cs — Derived protocol. Overrides CreateByteArrayResult to rent from ArrayPool when targetType == typeof(SignalData). Register this instead of AcBinaryHubProtocol.
  • SignalData.csIDisposable wrapper for byte[] with optional ArrayPool lifecycle. Span for zero-copy access, Dispose() returns rented buffer. Created by AyCodeBinaryHubProtocol (pooled) or directly from byte[] (server send).

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, ResponseData is SignalData?, supports JSON/Binary with GZip, caching, diagnostics, Dispose() returns buffers to ArrayPool).
  • IAcSignalRHubBase.cs — Base hub interface: OnReceiveMessage(int messageTag, int? requestId, SignalParams signalParams, SignalData data).
  • ISignalParams.csISignalParams base interface + SignalParams (Status, DataSerializerType, Parameters byte[]?). Metadata travels as separate hub argument (AcBinary serialized), payload SignalData uses protocol fast-path (ArrayPool-backed). Parameters and data are independent — both nullable in any direction.

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.