Realtime
Realtime in the .NET SDK.
RealtimeResource
classclass Inverge.Nexus.Resources.RealtimeResourceRealtime rooms — emit from your server, and manage the room registry.
Rooms are environment-scoped. A subscriber connected with a key
from a different environment is not in the room you emitted to, and the emit
succeeds with zero recipients. That silence is the single most common realtime
problem, and Recipients is how you spot it.
This resource only emits. To receive events in .NET — a worker reacting
to room traffic, a bridge — use Inverge.Nexus.Realtime.
BroadcastAsync()
methodTask<BroadcastResult> BroadcastAsync(IEnumerable<RoomMessage> messages, CancellationToken cancellationToken = default)Sends to many rooms, each with its own events and payload, in one request.
Parameters
Prop
Type
Returns Task<BroadcastResult>
ClearSchemaAsync()
methodTask<NexusAck> ClearSchemaAsync(string roomId, CancellationToken cancellationToken = default)Removes the room's schema entirely.
Parameters
Prop
Type
Returns Task<NexusAck>
DeleteRoomAsync()
methodTask<NexusAck> DeleteRoomAsync(string roomId, CancellationToken cancellationToken = default)Deletes a registered room.
Parameters
Prop
Type
Returns Task<NexusAck>
EmitAsync()
methodTask<EmitResult> EmitAsync(string room, string eventName, object? payload = null, CancellationToken cancellationToken = default)Emits one named event to a room.
await nexus.Realtime.EmitAsync("orders:42", "status", new { state = "shipped" });Parameters
Prop
Type
Returns Task<EmitResult>
EmitAsync()
methodTask<EmitResult> EmitAsync(string room, IEnumerable<string> events, object? payload = null, CancellationToken cancellationToken = default)Emits several named events to a room, with one payload.
Parameters
Prop
Type
Returns Task<EmitResult>
EmitAsync()
methodTask<EmitResult> EmitAsync(RoomMessage message, CancellationToken cancellationToken = default)Emits a prepared message.
Parameters
Prop
Type
Returns Task<EmitResult>
EmitToRoomsAsync()
methodTask<BroadcastResult> EmitToRoomsAsync(IEnumerable<string> rooms, string eventName, object? payload = null, CancellationToken cancellationToken = default)Sends the same event and payload to several rooms, in one request.
Parameters
Prop
Type
Returns Task<BroadcastResult>
EnableSchemaAsync()
methodTask<RoomSchemaResult> EnableSchemaAsync(string roomId, bool enabled = true, CancellationToken cancellationToken = default)Turns schema validation on or off for a room.
Parameters
Prop
Type
Returns Task<RoomSchemaResult>
GetSchemaAsync()
methodTask<RoomSchemaResult> GetSchemaAsync(string roomId, CancellationToken cancellationToken = default)The room's payload schema, if one is set.
Parameters
Prop
Type
Returns Task<RoomSchemaResult>
LinkAsync()
methodTask<NexusAck> LinkAsync(string roomId, string relatedRoomId, CancellationToken cancellationToken = default)Links two rooms, so an emit to one also reaches the other.
Both arguments are room ids, not names — the ids from
RegisterRoomAsync or ListRoomsAsync.
Parameters
Prop
Type
Returns Task<NexusAck>
ListRoomsAsync()
methodTask<IReadOnlyList<JsonNode>> ListRoomsAsync(CancellationToken cancellationToken = default)The environment's registered rooms.
Parameters
Prop
Type
Returns Task<IReadOnlyList<JsonNode>>
RegisterRoomAsync()
methodTask<RoomResult> RegisterRoomAsync(string name, string? type = null, CancellationToken cancellationToken = default)Registers a room up front. Rooms are also created on first join or emit, so this is for naming and typing them deliberately.
Parameters
Prop
Type
Returns Task<RoomResult>
RelatedAsync()
methodTask<IReadOnlyList<string>> RelatedAsync(string roomName, CancellationToken cancellationToken = default)Rooms linked to this one, by room name.
Parameters
Prop
Type
Returns Task<IReadOnlyList<string>>
SetSchemaAsync()
methodTask<RoomSchemaResult> SetSchemaAsync(string roomId, object schema, CancellationToken cancellationToken = default)Attaches a JSON Schema that payloads to this room must satisfy.
Attaching a schema does not enforce it — call
EnableSchemaAsync for that. Once enforced, an emit whose
payload fails validation is rejected with a validation error rather than
delivered.
Parameters
Prop
Type
Returns Task<RoomSchemaResult>
UnlinkAsync()
methodTask<NexusAck> UnlinkAsync(string roomId, string relatedRoomId, CancellationToken cancellationToken = default)Removes a link between two rooms.
Parameters
Prop
Type
Returns Task<NexusAck>
