Hmz.Core.Realtime.Abstractions
0.1.0
dotnet add package Hmz.Core.Realtime.Abstractions --version 0.1.0
NuGet\Install-Package Hmz.Core.Realtime.Abstractions -Version 0.1.0
<PackageReference Include="Hmz.Core.Realtime.Abstractions" Version="0.1.0" />
<PackageVersion Include="Hmz.Core.Realtime.Abstractions" Version="0.1.0" />
<PackageReference Include="Hmz.Core.Realtime.Abstractions" />
paket add Hmz.Core.Realtime.Abstractions --version 0.1.0
#r "nuget: Hmz.Core.Realtime.Abstractions, 0.1.0"
#:package Hmz.Core.Realtime.Abstractions@0.1.0
#addin nuget:?package=Hmz.Core.Realtime.Abstractions&version=0.1.0
#tool nuget:?package=Hmz.Core.Realtime.Abstractions&version=0.1.0
Hmz.Core.Realtime.Abstractions
The contracts of the Hmz realtime engine (Hmz.Core.Realtime): what a feature calls to push a
live hint to connected clients, and the seams an adapter implements to change how events travel.
The package has no ASP.NET Core dependency, so a Contracts, Domain or worker project can publish.
Namespace: Hmz.Core.Realtime.Abstractions.
Types
| Type | Purpose |
|---|---|
IRealtimePublisher |
The application port. Best effort and losable: never throws for a delivery failure. |
RealtimePublisherExtensions.PublishAsync<T>(type, audience, data, JsonTypeInfo<T>, eventId?, ct) |
Serializes the payload once with source-generated JSON and publishes it. |
RealtimeEvent |
Type, audience, optional id and the payload as UTF-8 JSON, shared by every recipient. RealtimeEvent.Create<T> serializes. |
RealtimeEventTypes |
Type-name rules (IsValid, MaxLength) and the reserved heartbeat type Ping (ping). |
RealtimeAudience, RealtimeUserAudience |
Who receives an event: RealtimeAudience.User(id) / Users(ids) today; groups or topics can be added later. |
IRealtimeBackplane |
Fan-out across instances: PublishAsync and Subscribe(transport) for local delivery. |
IRealtimeTransport |
The transport seam (SSE built in; a SignalR adapter later): Deliver, HasConnection, Name. |
IRealtimePresence |
MayBeConnected(userId): lets a publisher skip per-user work for users nobody would receive it for. |
IRealtimeEventAuthorizer, RealtimeSubscriber |
Optional per-connection filter: may this connection receive this event type? |
Rules
- Publish only what is durable. Publish after the transaction that wrote the fact has committed: a client that reacts and refetches must see the change. Events are hints, never the source of truth; a lost event costs a late refresh.
- Event types are 1 to 100 ASCII letters, digits,
.,_,:or-(notification,report.ready).pingis reserved for the stream heartbeat. An invalid type or id throwsArgumentExceptionat publish time (a programming error), never a delivery error. - Event ids are optional (at most 200 characters, no line break or NUL). A client may use them to de-duplicate; the stream does not replay missed events.
- Payloads are serialized once, at publish time, with a caller-supplied
JsonTypeInfo<T>(no reflection, AOT friendly). Everything downstream carries the same bytes, so an out-of-process backplane moves them as they are. - Audiences are a closed set of kinds owned by this package. A transport skips a kind it does not know, so an event never reaches the wrong people.
Usage
[JsonSerializable(typeof(ReportReady))]
internal sealed partial class ReportJsonContext : JsonSerializerContext;
public sealed record ReportReady(Guid ReportId, string Name);
await publisher.PublishAsync(
"report.ready",
RealtimeAudience.User(requestedBy),
new ReportReady(report.Id, report.Name),
ReportJsonContext.Default.ReportReady,
eventId: report.Id.ToString("D"),
ct);
Writing an adapter
- Backplane (several instances): implement
IRealtimeBackplane, move the type, id, audience and payload bytes between instances, and on each instance hand every event to the subscribed transports. ImplementIRealtimePresencetoo if you can tell who is connected anywhere; otherwise every user counts as possibly connected. Register it from your own extension method (services.AddRealtimeRedisBackplane(...)) afterAddRealtime. - Transport (for example SignalR): implement
IRealtimeTransport, register it withTryAddEnumerableas a singleton, mapRealtimeUserAudienceto your users, and never block inDeliver. Ask every registeredIRealtimeEventAuthorizerthroughCanReceiveAsyncoff the publisher's thread (queue the event, decide in the connection's loop), from the DI scope of the connection's request (or one your transport keeps per connection), and cache the answer per connection and type. HandleRealtimeEventTypes.Reconnectas a control event: deliver it to every connection of the audience regardless of filters and authorizers, then close those connections. Return true fromHasConnectionif you do not track users.
Registration, the in-process backplane and the server-sent events stream are in the
Hmz.Core.Realtime package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Hmz.Core.Realtime.Abstractions:
| Package | Downloads |
|---|---|
|
Hmz.Core.Realtime
Reusable realtime delivery engine for Hmz backends on ASP.NET Core: a best-effort publisher, an in-process backplane and one multiplexed server-sent events stream per client, each replaceable by an adapter package. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 76 | 11/17/2026 |