Refactor synchronous PipeReader/PipeWriter usage to avoid Task allocations via fast-path helpers. Add detailed debug/trace logging for chunked message flows and deserialization. Track active reads to prevent protocol errors. Refactor FindStreamedArgSlot and introduce ResolveStreamedArgType for dynamic streamed arg type resolution, with AyCodeBinaryHubProtocol override. Minor code cleanups and improved logging context throughout. Improves performance, correctness, and debuggability. |
||
|---|---|---|
| .. | ||
| AcBinaryHubProtocol.cs | ||
| AcSignalRClientBase.cs | ||
| AcSignalRTags.cs | ||
| AyCodeBinaryHubProtocol.cs | ||
| BinaryProtocolMode.cs | ||
| IAcSignalRHubBase.cs | ||
| IAcSignalRHubClient.cs | ||
| ISignalParams.cs | ||
| README.md | ||
| SendToClientType.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 three-path read logic seeAyCode.Services/docs/SIGNALR_BINARY_PROTOCOL.md. Known issues:AyCode.Services/docs/SIGNALR_ISSUES.md
Key Files
Protocol
AcBinaryHubProtocol.cs— Unsealed baseIHubProtocolreplacing JSON+Base64 withAcBinarySerializer. Handles all 9 SignalR message types. Write:BufferWriterBinaryOutputstandalone +AcBinarySerializer.Serialize(value, output)zero-copy to pipe.byte[]fast-path writes tag+VarUInt+bytes via BWO. Read:SequenceReader<byte>from pipe'sReadOnlySequence. Three-pathReadSingleArgument: byte[] fast-path (0x44 tag),IsRawBytesData(raw byte[]), typed deser viaSignalDataType._currentSignalParamscaptures arg[2] for type-aware arg[3] deserialization.AyCodeBinaryHubProtocol.cs— Derived protocol (currently empty). Exists for registration and future project-specific hooks. Register this instead ofAcBinaryHubProtocol.
Client
AcSignalRClientBase.cs— Abstract SignalR client managingHubConnection, request/response tracking via pooledSignalRRequestModel.SendCoreAsyncbuildsSignalParams(withIsRawBytesDatawhenT == byte[]). CRUD helpers (Post, Get, GetAll, GetAllInto). Configurable timeouts.IAcSignalRHubClient.cs— Client interface +SignalResponseDataMessage(sealed,RawResponseDataisobject?— typed object or byte[],GetResponseData<T>()direct cast). Legacy message types (IdMessage,SignalPostJsonDataMessage) marked[Obsolete].IAcSignalRHubBase.cs— Base hub interface:OnReceiveMessage(int messageTag, int? requestId, SignalParams signalParams, object data).ISignalParams.cs—ISignalParamsbase interface +SignalParams(Status, DataSerializerType, Parametersbyte[]?, SignalDataTypestring?, IsRawBytesDatabool). Metadata travels as separate hub argument (AcBinary serialized). 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.SignalRRequestModel.cs— Poolable (IResettable) request tracking model withObjectPoolfor reuse.