Kanject.Core.Realtime.Abstractions
1.0.0
Prefix Reserved
See the version list below for details.
dotnet add package Kanject.Core.Realtime.Abstractions --version 1.0.0
NuGet\Install-Package Kanject.Core.Realtime.Abstractions -Version 1.0.0
<PackageReference Include="Kanject.Core.Realtime.Abstractions" Version="1.0.0" />
<PackageVersion Include="Kanject.Core.Realtime.Abstractions" Version="1.0.0" />
<PackageReference Include="Kanject.Core.Realtime.Abstractions" />
paket add Kanject.Core.Realtime.Abstractions --version 1.0.0
#r "nuget: Kanject.Core.Realtime.Abstractions, 1.0.0"
#:package Kanject.Core.Realtime.Abstractions@1.0.0
#addin nuget:?package=Kanject.Core.Realtime.Abstractions&version=1.0.0
#tool nuget:?package=Kanject.Core.Realtime.Abstractions&version=1.0.0
Kanject.Core.Realtime.Abstractions
The transport-neutral contract for pushing messages to connected clients (Core proposal 0058). A product publishes to an audience, which is a user, several users or a topic, through IRealtimePublisher. The host decides whether the message travels in process, over API Gateway WebSockets or over AppSync Events. The package depends only on the BCL.
Installation
dotnet add package Kanject.Core.Realtime.Abstractions
Targets .NET 9, .NET 10 and .NET 11. Add Kanject.Core.Realtime for AddRealtime() and the in-process transport.
Quick start
public sealed class ConversationBroadcaster(IRealtimePublisher realtime)
{
public Task<RealtimePublishResult> MessageAddedAsync(Conversation conversation, MessageAdded added, CancellationToken ct) =>
realtime.PublishAsync(
conversation.IsLargeRoom
? RealtimeAudience.Topic("Conversations", conversation.Id)
: RealtimeAudience.Users(conversation.ParticipantIds),
type: "message_added", added, ChatJsonContext.Default.MessageAdded, requestId: added.RequestId, ct);
}
The product says who a caller is and what they may listen to, once, for every transport:
public sealed class ChatRealtimeAuthorizer(ITokenValidator tokens, IConversationReader conversations) : IRealtimeAuthorizer
{
public async ValueTask<RealtimePrincipal?> AuthenticateAsync(RealtimeConnectRequest request, CancellationToken ct) =>
await tokens.ValidateAsync(request.Token, ct) is { IsValid: true } token
? new RealtimePrincipal(token.UserId, token.ExpiresAt)
: null;
public ValueTask<bool> CanSubscribeAsync(RealtimePrincipal principal, RealtimeTopic topic, CancellationToken ct) =>
topic.Kind == "Conversations" ? conversations.IsParticipantAsync(topic.Id, principal.UserId, ct) : ValueTask.FromResult(false);
}
The envelope
Every transport delivers the same JSON, so one client parser serves all of them:
{ "type": "message_added", "id": "0193a4c6-…", "requestId": "0193a4c5-…", "sentAt": "2026-11-23T10:15:00.0000000Z", "data": { … } }
idis Core's, a new version-7Guidfor each publish. A client drops anidit has already seen.requestIdis the one the sending client minted, so that client can drop its own echo. It is left out when there is none.datagoes through yourJsonTypeInfo<T>; Core never reflects.RealtimeEnvelopeJsonwrites and reads the envelope.
Rules every transport applies
- A topic's kind is a PascalCase plural noun of 1–50 letters and digits, such as
Conversations.Usersis reserved in any casing (KANRT001). - A message type is 1–64 lower-case letters, digits,
_,.or-, starting with a letter, such asmessage_added(KANRT005). - The payload ceiling is 32 KB, the whole envelope, one API Gateway frame. An envelope over it is refused before anything is sent (KANRT003). A host may raise it to its transport's own limit.
- Core's four subscription rules come before your authorizer (
RealtimeSubscriptionRules). A principal subscribes to its own user channel and no one else's. A wildcard is always refused. A principal stays inside its own tenant, taken from the principal and never from the request. Nothing is delivered after the principal expires, where the transport can end a connection.
Capabilities
The transports differ. API Gateway lists and ends connections; AppSync Events fans out itself but can't end a subscription. Each transport reports a RealtimeCapabilities, and a member it can't serve throws RealtimeCapabilityNotSupportedException naming the capability (KANRT004). Branch on the capabilities, never on a provider's type.
Diagnostics
| Code | Meaning |
|---|---|
| KANRT001 | A topic kind is malformed or reserved |
| KANRT002 | RealtimeAudience.Users names no user |
| KANRT003 | An envelope is over the payload ceiling |
| KANRT004 | A member needs a capability the transport lacks |
| KANRT005 | A message type is malformed |
| KANRT006 | Text isn't Core's envelope |
License
Licensed under the Kanject Code Libraries License Agreement (KCLLA); the full text ships in this package as LICENSE.md. Organizations whose trailing-twelve-month gross revenue and total funding raised are each below US$250,000 may use it at no cost under the Free Tier. At or above either threshold a commercial license is required — contact commercial@kanjectbusiness.com.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. net11.0 is compatible. |
-
net10.0
- No dependencies.
-
net11.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Kanject.Core.Realtime.Abstractions:
| Package | Downloads |
|---|---|
|
Kanject.Core.Realtime
Kanject Core realtime — AddRealtime() and the in-process default transport for Kanject.Core.Realtime.Abstractions (proposal 0058): connections, subscriptions and delivery held in memory, with Core's subscription rules, the product's IRealtimeAuthorizer, the connection observer, inbound frames and every D10 control. For tests and local runs; providers for API Gateway WebSockets and AppSync Events plug into the same builder. |
GitHub repositories
This package is not used by any popular GitHub repositories.