AyCode.Core/AyCode.Services/SignalRs
Loretta 2d04b9f8f6 Zero-copy SignalR: direct object response, no SignalData
Major overhaul for SignalR response pipeline:
- All deserialization now uses byte[] (offset/length) for zero-copy, allocation-free operation; all span/memory overloads removed.
- SignalR protocol sends (signalParams, object) directly; SignalData envelope and related logic removed.
- Server sets SignalParams.SignalDataType so protocol deserializes to the correct runtime type on the client.
- SignalResponseDataMessage now only used for client request/response tracking and stream path; RawResponseData holds the actual object.
- All extension methods, helpers, and infrastructure updated to use new byte[]-based APIs.
- AcSignalRDataSource and all test/benchmark code updated for new object flow.
- Removes all diagnostics, logging, and error handling related to binary envelopes.
- Enables true zero-copy, type-safe, allocation-free SignalR response handling.
2026-04-06 22:45:00 +02:00
..
AcBinaryHubProtocol.cs Zero-copy SignalR: direct object response, no SignalData 2026-04-06 22:45:00 +02:00
AcSignalRClientBase.cs Zero-copy SignalR: direct object response, no SignalData 2026-04-06 22:45:00 +02:00
AcSignalRTags.cs Refactor JSON/SignalR infra; add full test & benchmark suite 2025-12-11 21:25:50 +01:00
AyCodeBinaryHubProtocol.cs Zero-copy SignalR: direct object response, no SignalData 2026-04-06 22:45:00 +02:00
IAcSignalRHubBase.cs Zero-copy SignalR: direct object response, no SignalData 2026-04-06 22:45:00 +02:00
IAcSignalRHubClient.cs Zero-copy SignalR: direct object response, no SignalData 2026-04-06 22:45:00 +02:00
ISignalParams.cs Zero-copy SignalR: direct object response, no SignalData 2026-04-06 22:45:00 +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
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 Zero-copy SignalR: direct object response, no SignalData 2026-04-06 22:45:00 +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.