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. |
||
|---|---|---|
| .. | ||
| AcBinaryHubProtocol.cs | ||
| AcSignalRClientBase.cs | ||
| AcSignalRTags.cs | ||
| AyCodeBinaryHubProtocol.cs | ||
| IAcSignalRHubBase.cs | ||
| IAcSignalRHubClient.cs | ||
| ISignalParams.cs | ||
| README.md | ||
| SendToClientType.cs | ||
| SignalData.cs | ||
| SignalMessageTagAttribute.cs | ||
| SignalRCrudTags.cs | ||
| SignalRRequestModel.cs | ||
| SignalRSerializationHelper.cs | ||
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 seeAyCode.Services/docs/SIGNALR_BINARY_PROTOCOL.md.
Key Files
Protocol
AcBinaryHubProtocol.cs— Unsealed baseIHubProtocolreplacing JSON+Base64 withAcBinarySerializer. Handles all 9 SignalR message types. UsesBufferWriterBinaryOutputstandalone mode for zero-copy writes.byte[]/SignalDatafast-path bypasses serializer.CreateByteArrayResultvirtual hook for derived protocols. InnerSpanReaderref struct for zero-alloc parsing.AyCodeBinaryHubProtocol.cs— Derived protocol. OverridesCreateByteArrayResultto rent fromArrayPoolwhentargetType == typeof(SignalData). Register this instead ofAcBinaryHubProtocol.SignalData.cs—IDisposablewrapper forbyte[]with optionalArrayPoollifecycle.Spanfor zero-copy access,Dispose()returns rented buffer. Created byAyCodeBinaryHubProtocol(pooled) or directly frombyte[](server send).
Client
AcSignalRClientBase.cs— Abstract SignalR client managingHubConnection, request/response tracking via pooledSignalRRequestModel. Methods:SendMessageToServerAsync<TResponse>(), CRUD helpers (Post, Get, GetAll, GetAllInto). Configurable timeouts.IAcSignalRHubClient.cs— Client interface +SignalResponseDataMessage(sealed,ResponseDataisSignalData?, 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.cs—ISignalParamsbase interface +SignalParams(Status, DataSerializerType, Parametersbyte[]?). Metadata travels as separate hub argument (AcBinary serialized), payloadSignalDatauses 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()mapsTrackingState-> tag. SeeAyCode.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 withObjectPoolfor reuse.