AyCode.Core/AyCode.Services.Server/SignalRs
Loretta b1cdf80fad Fix SignalR binary protocol: VarUInt framing & type-safe ser
- Add type-explicit ToBinary/SerializeToBinary overloads to preserve runtime type info for object? serialization, fixing deserialization bugs.
- Refactor VarUInt encoding/decoding to a prefix-tiered scheme (1–5 bytes), replacing LEB128 and preventing buffer overrun/corruption.
- Update all SignalR and serialization call sites to use new overloads.
- Sync SignalR binary protocol VarUInt decoding logic; fix test regressions.
- Add SIGNALR_BINARY_PROTOCOL_VARUINT.md with new wire-format spec and rationale.
- Add debug logging for argument serialization.
- Update .gitignore to not ignore itself.
- Resolves 65 KB value cap and missing in-band abort marker; requires both sender/receiver to use new framing for full compatibility.
2026-05-27 05:47:23 +02:00
..
AcLoggerSignalRHub.cs Implement SignalRLoggerClient 2025-09-02 11:48:05 +02:00
AcSessionService.cs Add SignalR common services and dependencies 2025-08-31 12:39:47 +02:00
AcSignalRDataSource.cs Fix SignalR binary protocol: VarUInt framing & type-safe ser 2026-05-27 05:47:23 +02:00
AcSignalRSendToClientService.cs [LOADED_DOCS: .github\copilot-instructions.md] 2026-04-19 12:58:31 +02:00
AcSignalRServerProtocolExtensions.cs [LOADED_DOCS: 3 files, no new loads] 2026-05-03 15:21:15 +02:00
AcWebSignalRHubBase.cs Fix SignalR binary protocol: VarUInt framing & type-safe ser 2026-05-27 05:47:23 +02:00
ExtensionMethods.cs Refactor JSON/SignalR infra; add full test & benchmark suite 2025-12-11 21:25:50 +01:00
IAcSessionItem.cs Add SignalR common services and dependencies 2025-08-31 12:39:47 +02:00
IAcSignalRHubItemServer.cs improvements, fixes, etc 2024-05-25 22:16:22 +02:00
README.md [LOADED_DOCS: 3 files, no new loads] 2026-04-28 06:36:39 +02:00
TrackingItemHelpers.cs Add SignalR common services and dependencies 2025-08-31 12:39:47 +02:00

README.md

SignalRs

Server-side SignalR hub infrastructure: hub base class, session management, data source with change tracking, and client broadcast service.

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

Key Files

Hub

  • AcWebSignalRHubBase.cs — Abstract hub extending Hub<IAcSignalRHubItemServer>. Manages connection lifecycle, message dispatch via DynamicMethodRegistry, binary/JSON parameter deserialization. Response methods: ResponseToCaller(), SendMessageToOthers(), SendMessageToUserIdInternal().
  • IAcSignalRHubItemServer.cs — Server hub interfaces: IAcSignalRHubItemServer, IAcSignalRHubServer.
  • AcLoggerSignalRHub.cs — Specialized hub for receiving log items via SignalR (AddLogItem()).

Session & Broadcast

  • AcSessionService.cs — Generic session manager with ConcurrentDictionary<TSessionItemId, TSessionItem>.
  • IAcSessionItem.cs — Session item interface with SessionId property.
  • AcSignalRSendToClientService.cs — Abstract broadcast service: SendMessageToClient(), SendMessageToAllClients(), SendMessageToConnection(), SendMessageToUser().

Data Source

Full specification: AyCode.Services.Server/docs/SIGNALR_DATASOURCE/README.md

  • AcSignalRDataSource.cs — Generic real-time collection (AcSignalRDataSource<TDataItem, TId, TIList>) implementing IList<T> with full CRUD and change tracking.
    • Change tracking: TrackingItem<T, TId> wraps each modified item with TrackingState + OriginalValue for rollback. ChangeTracking<T, TId> manages the tracking list.
    • Loading: LoadDataSource() (sync), LoadDataSourceAsync() (async callback), LoadItem(id) (single). Binary path uses BinaryToMerge() for AcObservableCollection (batch UI update via BeginUpdate/EndUpdate).
    • Saving: SaveChanges() iterates tracked items, posts each via CRUD tag, rollbacks on failure. SaveItem() for individual saves.
    • Sync state: IsSyncing (Interlocked counter) + OnSyncingStateChanged event for UI loading indicators.
    • Locking: object _syncRoot (sync ops) + SemaphoreSlim _asyncLock (async ops). GetEnumerator() returns safe copy.
    • Working reference list: SetWorkingReferenceList() allows external list to become inner storage (zero-copy).
    • Context: ContextIds (object[]) + FilterText (string) sent with GetAll requests for server-side filtering.

Utilities

  • ExtensionMethods.csInvokeMethod() — invokes methods and unwraps Task/Task<T>/ValueTask results.
  • TrackingItemHelpers.cs — Deep clone helpers: JsonClone<T>(), ReflectionClone<T>().