InvergeDocs
.NETAPI reference

Realtime

Realtime in the .NET SDK.

RealtimeResource

class
class Inverge.Nexus.Resources.RealtimeResource

Realtime 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()

method
Task<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()

method
Task<NexusAck> ClearSchemaAsync(string roomId, CancellationToken cancellationToken = default)

Removes the room's schema entirely.

Parameters

Prop

Type

Returns Task<NexusAck>

DeleteRoomAsync()

method
Task<NexusAck> DeleteRoomAsync(string roomId, CancellationToken cancellationToken = default)

Deletes a registered room.

Parameters

Prop

Type

Returns Task<NexusAck>

EmitAsync()

method
Task<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()

method
Task<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()

method
Task<EmitResult> EmitAsync(RoomMessage message, CancellationToken cancellationToken = default)

Emits a prepared message.

Parameters

Prop

Type

Returns Task<EmitResult>

EmitToRoomsAsync()

method
Task<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()

method
Task<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()

method
Task<RoomSchemaResult> GetSchemaAsync(string roomId, CancellationToken cancellationToken = default)

The room's payload schema, if one is set.

Parameters

Prop

Type

Returns Task<RoomSchemaResult>

LinkAsync()

method
Task<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()

method
Task<IReadOnlyList<JsonNode>> ListRoomsAsync(CancellationToken cancellationToken = default)

The environment's registered rooms.

Parameters

Prop

Type

Returns Task<IReadOnlyList<JsonNode>>

RegisterRoomAsync()

method
Task<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()

method
Task<IReadOnlyList<string>> RelatedAsync(string roomName, CancellationToken cancellationToken = default)

Rooms linked to this one, by room name.

Parameters

Prop

Type

Returns Task<IReadOnlyList<string>>

SetSchemaAsync()

method
Task<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()

method
Task<NexusAck> UnlinkAsync(string roomId, string relatedRoomId, CancellationToken cancellationToken = default)

Removes a link between two rooms.

Parameters

Prop

Type

Returns Task<NexusAck>

On this page