Table of Contents

Class EventBridge

Namespace
RisingV.Shared
Assembly
RisingV.Shared.dll

Provides a centralized event bus for handling various game events.

public static class EventBridge
Inheritance
EventBridge
Inherited Members

Methods

Dispose()

Disposes the underlying global EventBus and releases all subscriptions. Call during server shutdown.

public static void Dispose()

PublishAsync<TEvent>(TEvent, CancellationToken)

Publishes evt asynchronously to all subscribers. Exceptions propagate to the caller.

public static ValueTask PublishAsync<TEvent>(TEvent evt, CancellationToken ct = default) where TEvent : IEvent

Parameters

evt TEvent
ct CancellationToken

Returns

ValueTask

Type Parameters

TEvent

PublishSafeAsync<TEvent>(TEvent, CancellationToken)

Publishes evt asynchronously, swallowing subscriber exceptions and logging them instead.

public static ValueTask PublishSafeAsync<TEvent>(TEvent evt, CancellationToken ct = default) where TEvent : IEvent

Parameters

evt TEvent
ct CancellationToken

Returns

ValueTask

Type Parameters

TEvent

PublishSafe<TEvent>(TEvent, CancellationToken)

Synchronous “safe” publish variant: subscriber exceptions are caught and logged.

public static void PublishSafe<TEvent>(TEvent evt, CancellationToken ct = default) where TEvent : IEvent

Parameters

evt TEvent
ct CancellationToken

Type Parameters

TEvent

Publish<TEvent>(TEvent, CancellationToken)

Synchronously publishes evt to all listeners.

public static void Publish<TEvent>(TEvent evt, CancellationToken ct = default) where TEvent : IEvent

Parameters

evt TEvent
ct CancellationToken

Type Parameters

TEvent

Subscribe<TEvent>(object, EventHandler<TEvent>, int)

Subscribes an asynchronous handler to TEvent
and returns an IDisposable that removes the subscription when disposed.

public static IDisposable Subscribe<TEvent>(object owner, EventHandler<TEvent> handler, int handlerHash = 0) where TEvent : IEvent

Parameters

owner object
handler EventHandler<TEvent>
handlerHash int

Returns

IDisposable

Type Parameters

TEvent

Subscribe<TEvent>(object, Action<TEvent>)

Subscribes a synchronous Action<T> handler.

public static IDisposable Subscribe<TEvent>(object owner, Action<TEvent> handler) where TEvent : IEvent

Parameters

owner object
handler Action<TEvent>

Returns

IDisposable

Type Parameters

TEvent

Subscribe<TEvent>(object, Func<TEvent, ValueTask>)

Subscribes a Func<TResult> asynchronous handler.

public static IDisposable Subscribe<TEvent>(object owner, Func<TEvent, ValueTask> handler) where TEvent : IEvent

Parameters

owner object
handler Func<TEvent, ValueTask>

Returns

IDisposable

Type Parameters

TEvent

Unsubscribe(object)

Removes owner's entire subscription set.

public static void Unsubscribe(object owner)

Parameters

owner object

Unsubscribe<TEvent>(object, EventHandler<TEvent>)

Unsubscribes a previously registered asynchronous handler.

public static void Unsubscribe<TEvent>(object owner, EventHandler<TEvent> handler) where TEvent : IEvent

Parameters

owner object
handler EventHandler<TEvent>

Type Parameters

TEvent

Unsubscribe<TEvent>(object, Action<TEvent>)

Unsubscribes a previously registered synchronous handler.

public static void Unsubscribe<TEvent>(object owner, Action<TEvent> handler) where TEvent : IEvent

Parameters

owner object
handler Action<TEvent>

Type Parameters

TEvent