Files
2026-04-17 14:55:32 -04:00

3.2 KiB
Raw Permalink Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.CommonCore/Events/Realtime/RealtimeChannelSelectedEvent.cs
2026-04-16T02:48:30.854477+00:00 Qwen/Qwen3-Coder-Next-FP8 1 b5b90e6c3d17fb4a

Realtime

1. Purpose

This module defines the RealtimeChannelSelectedEvent, a Prism-based event used to propagate notifications across the application when a realtime communication channel is selected. It serves as a decoupling mechanism in the event-driven architecture, enabling subscribers (e.g., UI components, services, or modules) to react to channel selection changes—such as updating UI state, initializing connections, or switching data streams—without tight coupling to the publisher.

2. Public Interface

  • RealtimeChannelSelectedEvent
    • Type: class (inherits from CompositePresentationEvent<IRealtimeChannel>)
    • Behavior: A Prism event token used for publishing and subscribing to channel selection events. When published, it carries an IRealtimeChannel instance representing the newly selected channel. Subscribers receive this instance via their event handler.
    • Note: No additional public methods or properties are defined beyond those inherited from CompositePresentationEvent<TPayload> (e.g., Subscribe, Publish, GetSubscriptionToken).

3. Invariants

  • The payload passed via Publish must be a non-null instance of IRealtimeChannel (enforced by convention, though not explicitly validated in this class).
  • The event is intended for thread-safe use within Prisms event system (i.e., subscriptions/publishing may occur on any thread, with Prism handling dispatch to the UI thread if configured to do so).
  • The event payload type is strictly IRealtimeChannel; no other types are supported.

4. Dependencies

  • Depends on:
    • DTS.Common.Interface.Realtime.IRealtimeChannel (interface defining the realtime channel contract)
    • Microsoft.Practices.Prism.Events.CompositePresentationEvent<T> (Prism event infrastructure)
  • Used by:
    • Components that publish channel selection changes (e.g., a channel manager or UI view model).
    • Subscribers (e.g., data handlers, logging modules, or UI elements) that need to respond to channel changes.
      (Exact consumers are not visible in this file but are implied by the events purpose.)

5. Gotchas

  • No explicit validation: The class does not validate the IRealtimeChannel payload; subscribers must handle null or invalid channel states defensively.
  • Lifetime management: Subscribers must manually unsubscribe (e.g., via SubscriptionToken) to avoid memory leaks—especially critical for long-lived subscribers (e.g., views) in Prisms event system.
  • Thread-safety assumptions: While Prisms CompositePresentationEvent handles thread dispatch, the behavior depends on the applications Prism configuration (e.g., ThreadOption.PublisherThread vs. UIThread).
  • Naming ambiguity: The class name RealtimeChannelSelectedEvent implies selection triggered by user action, but the source does not clarify whether it is also used for programmatic channel changes.