Kanject.Core.Realtime 1.3.0

Prefix Reserved
dotnet add package Kanject.Core.Realtime --version 1.3.0
                    
NuGet\Install-Package Kanject.Core.Realtime -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kanject.Core.Realtime" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kanject.Core.Realtime" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Kanject.Core.Realtime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kanject.Core.Realtime --version 1.3.0
                    
#r "nuget: Kanject.Core.Realtime, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kanject.Core.Realtime@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kanject.Core.Realtime&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Kanject.Core.Realtime&version=1.3.0
                    
Install as a Cake Tool

Kanject.Core.Realtime

AddRealtime() and the in-process transport for Kanject.Core.Realtime.Abstractions (Core proposal 0058). The in-process transport holds connections, subscriptions and delivery in memory, with Core's subscription rules, your IRealtimeAuthorizer, the connection observer and inbound frames. Use it for tests and local runs. The API Gateway WebSockets and AppSync Events providers plug into the same builder.

Installation

dotnet add package Kanject.Core.Realtime

Targets .NET 9, .NET 10 and .NET 11. It logs through PrintInConsole, so it brings Kanject.Core, and with it the ASP.NET Core shared framework.

Quick start

builder.Services.AddRealtime(realtime =>
{
    // One transport per host. With none chosen, the in-process transport.
    realtime.AuthorizeWith<HostRealtimeAuthorizer>();
    realtime.ObserveWith<PresenceObserver>();                   // optional; several may be added
    realtime.AddFrames<ChatFrames>();                           // optional; claimed by action
    realtime.AuthorizeTopicsWith<ConversationTopicAuthorizer>();// optional; claimed by topic kind
});

IRealtimePublisher, IRealtimeConnections and IRealtimeSubscriptions are scoped on every transport, so each publish reads the request's tenant from ITenantContext when the host has tenants. A publish reaches its own tenant's connections only. Without a tenant, it reaches only connections without one.

A test or a local tool connects a client the way a WebSocket would:

var connector = provider.GetRequiredService<IInProcessRealtimeConnector>();
await using var connection = await connector.ConnectAsync(new RealtimeConnectRequest(token, Device: "laptop"));
await connection!.SubscribeAsync(RealtimeTopic.Create("Conversations", conversationId));
RealtimeEnvelope envelope = await connection.ReceiveAsync();

Each client receives the envelope's JSON and reads it back, so a test sees exactly what a real client would.

What the in-process transport does

  • It reports every capability, with the strictest real limits: 128 KB a message and 40 subscriptions a connection. Code tested in process then doesn't pass a message a real transport refuses.
  • It ends a connection whose principal has expired when a publish meets it, and counts the connection gone. SyncAsync removes the rest.
  • renew replaces the principal only for the same user and tenant. Any other token changes nothing.
  • Observers run in a scope of their own. One that throws is logged (KANRT053) and the change stands. A user's first connection and last disconnection are never missed.
  • A second Use… call replaces the first transport and logs KANRT050, in the same AddRealtime call or a later one.
  • AddRealtime calls add up, so a library's registration and your host's can both call it, in either order. A call that names no transport leaves yours alone; the in-process transport is used only while no call has named one, and naming one over that default logs nothing. A call that leaves PayloadCeilingBytes unset keeps the ceiling. A later AuthorizeWith or HandleFramesWith replaces an earlier one, and observers add up. To put the in-process transport in place of another, in a test for instance, name it: AddRealtime(r => r.UseInProcess()).
  • Library contributions (proposal 0069):
    • AddFrames<T>() contributes an IRealtimeInboundHandler keyed by the actions T claims via IRealtimeFrameActionClaims. HandleFramesWith<T>() keeps its single-slot meaning and becomes the fallback for unclaimed actions and unreadable frames when contributions exist; with no fallback, Core refuses them through RefuseFrameAsync (UnknownAction / InvalidFrame).
    • AuthorizeTopicsWith<T>() contributes an IRealtimeTopicAuthorizer keyed by the topic kinds T claims via IRealtimeTopicKindClaims. Authentication stays one per host (AuthorizeWith), Core's four subscription rules still run first, a claimed kind goes only to its claimant, and unclaimed kinds fall back to the host's CanSubscribeAsync.
    • Each action or topic kind may be claimed once in a host (KANRT055 / KANRT056). Register the host's authorizer and fallback handler through AuthorizeWith / HandleFramesWith rather than directly on IServiceCollection (KANRT057; a direct registration made after the last AddRealtime call cannot be detected and shadows Core's router or composed authorizer). Contributions go through AddFrames<T>() / AuthorizeTopicsWith<T>() too: a keyed IRealtimeInboundHandler or IRealtimeTopicAuthorizer registered directly beside a contribution is KANRT057, and one keyed after the last call is only ever found under an action or kind a contribution claimed.
  • A transport says whether its clients send frames: UseTransport(name, register, clientsSendFrames). When they don't and a frame handler or contribution is registered, AddRealtime logs KANRT054, since it would never be called. AppSync Events says it; a transport that uses the two-argument overload doesn't, and gets no warning.
  • A refused frame (RefuseFrameAsync) is answered on the calling connection and logged as a warning.

Diagnostics

Code Meaning
KANRT050 A second transport replaced the first
KANRT051 A connection was refused because no IRealtimeAuthorizer is registered
KANRT053 An observer threw; the change stands
KANRT054 A frame handler or contribution is registered, but the transport's clients don't send frames
KANRT055 A frame action claim is duplicated, reserved by Core, outside the grammar, or null/empty
KANRT056 A topic kind claim is duplicated, reserved (Users), outside the grammar, null/empty, or empty list
KANRT057 A direct IRealtimeAuthorizer or IRealtimeInboundHandler registration sits beside a contribution for its slot, or a keyed IRealtimeInboundHandler or IRealtimeTopicAuthorizer registered directly sits beside a contribution

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Kanject.Core.Realtime:

Package Downloads
Kanject.Core.Realtime.Provider.AwsApiGateway

Kanject Core realtime over API Gateway WebSockets (proposal 0058 P2): UseApiGatewayWebSockets() posts to each connection through IAmazonApiGatewayManagementApi, bounded and queued for a large audience, with the connections in a registry the host chooses (IRealtimeConnectionRegistry; the DynamoDB one is its own package). The host's Lambda calls its connect, disconnect, message and fan-out entry points with plain values. Every D10 control: listing, ending, server-side subscriptions, renew and the registry sweep.

Kanject.Core.Realtime.TestKit

Kanject Core realtime contract suite (xUnit): RealtimeTransportContractTests, the tests every realtime transport passes (proposal 0058 §5), run through an IRealtimeTransportHost; plus TestRealtimeAuthorizer and RecordingRealtimePublisher, test doubles, and a host for the in-process transport.

Kanject.Core.Realtime.Provider.AwsAppSync

Kanject Core realtime over AWS AppSync Events (proposal 0058 P3): UseAppSyncEvents() makes IRealtimePublisher a SigV4-signed POST to the Event API's /event, one call per channel, and AWS fans out. Adapters for the Event API's Lambda authorizer and a namespace's direct-Lambda onSubscribe run the product's IRealtimeAuthorizer and Core's subscription rules. Holds no state. References AWSSDK.Core only.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 6 11/26/2026
1.2.0 57 11/26/2026
1.1.0 61 11/26/2026
1.0.0 65 11/24/2026

- Adds AddFrames<T>(), AuthorizeTopicsWith<T>(), frame action routing, and composed topic authorization (proposal 0069)
- Takes Kanject.Core.Realtime.Abstractions 1.3.0.