Kanject.Core.Realtime
1.2.0
Prefix Reserved
See the version list below for details.
dotnet add package Kanject.Core.Realtime --version 1.2.0
NuGet\Install-Package Kanject.Core.Realtime -Version 1.2.0
<PackageReference Include="Kanject.Core.Realtime" Version="1.2.0" />
<PackageVersion Include="Kanject.Core.Realtime" Version="1.2.0" />
<PackageReference Include="Kanject.Core.Realtime" />
paket add Kanject.Core.Realtime --version 1.2.0
#r "nuget: Kanject.Core.Realtime, 1.2.0"
#:package Kanject.Core.Realtime@1.2.0
#addin nuget:?package=Kanject.Core.Realtime&version=1.2.0
#tool nuget:?package=Kanject.Core.Realtime&version=1.2.0
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<ChatRealtimeAuthorizer>();
realtime.ObserveWith<PresenceObserver>(); // optional
realtime.HandleFramesWith<ChatFrames>(); // optional
});
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.
SyncAsyncremoves the rest. renewreplaces 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. - A transport says whether its clients send frames:
UseTransport(name, register, clientsSendFrames). When they don't and a frame handler is registered,AddRealtimelogs KANRT054, since the handler 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 is registered, but the transport's clients don't send frames |
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
- Kanject.Core (>= 4.3.0)
- Kanject.Core.Annotations (>= 4.0.1)
- Kanject.Core.Realtime.Abstractions (>= 1.2.0)
- Kanject.Core.Tenancy (>= 4.0.0)
-
net11.0
- Kanject.Core (>= 4.3.0)
- Kanject.Core.Annotations (>= 4.0.1)
- Kanject.Core.Realtime.Abstractions (>= 1.2.0)
- Kanject.Core.Tenancy (>= 4.0.0)
-
net9.0
- Kanject.Core (>= 4.3.0)
- Kanject.Core.Annotations (>= 4.0.1)
- Kanject.Core.Realtime.Abstractions (>= 1.2.0)
- Kanject.Core.Tenancy (>= 4.0.0)
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.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. |
|
|
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. |
GitHub repositories
This package is not used by any popular GitHub repositories.
- Routes declared client frames through a generated handler that refuses what it can't route.
- Takes Kanject.Core.Realtime.Abstractions 1.2.0.