Table of Contents

Class SubscriberGroupedService

Namespace
adas_core.Application.Subscriptions
Assembly
adas-core.Application.dll

Provides an implementation of ISubscriberGroupedService that coordinates subscription handling for grouped observations, integrating caching, client messaging, and logging capabilities.

public class SubscriberGroupedService : ISubscriberGroupedService
Inheritance
SubscriberGroupedService
Implements
Inherited Members
Extension Methods

Remarks

This service depends on an optional cache, a grouped observation service, a logger, and a lazily-initialized client message service to support its subscriber-related operations.

Constructors

SubscriberGroupedService(ICacheService?, IGroupedObservationService, ILogger<SubscriberGroupedService>, Lazy<IClientMessageService>)

Provides an implementation of ISubscriberGroupedService that coordinates subscription handling for grouped observations, integrating caching, client messaging, and logging capabilities.

public SubscriberGroupedService(ICacheService? cacheService, IGroupedObservationService groupedObservationService, ILogger<SubscriberGroupedService> logger, Lazy<IClientMessageService> clientMessageService)

Parameters

cacheService ICacheService
groupedObservationService IGroupedObservationService
logger ILogger<SubscriberGroupedService>
clientMessageService Lazy<IClientMessageService>

Remarks

This service depends on an optional cache, a grouped observation service, a logger, and a lazily-initialized client message service to support its subscriber-related operations.

Properties

SubscriberGroupedList

public List<WsSubscriberGrouped> SubscriberGroupedList { get; set; }

Property Value

List<WsSubscriberGrouped>

Methods

AddSubscriberGrouped(WsSubscriberGrouped)

Adds a grouped WebSocket subscriber to the internal collection in a thread-safe manner. Uses locking to ensure that concurrent calls do not corrupt the subscriber list.

public void AddSubscriberGrouped(WsSubscriberGrouped wsSubscriberGrouped)

Parameters

wsSubscriberGrouped WsSubscriberGrouped

The grouped WebSocket subscriber instance to be added to the collection.

CheckEmptySubscriberGroup(WsSubscriberGrouped?)

Check clients using generated grouped observations on disconections removing the wole object in case of 0 or only the group if any other client is using it

public List<string> CheckEmptySubscriberGroup(WsSubscriberGrouped? wsSubscriberGrouped)

Parameters

wsSubscriberGrouped WsSubscriberGrouped

Object with properties to generate new grouped observations, clients using those grouped obsercations and the generated list of grouped observations

Returns

List<string>

CheckOnSubscriptionGroup(GroupedField, ObjectId, string?, string, GroupedObservation)

Registers a client connection for grouped-field observation updates for a given patient. If an existing grouped subscription matches the patient and field, the connection is added to it; otherwise, a new grouped subscription is created with a callback that processes empty observations.

public void CheckOnSubscriptionGroup(GroupedField groupedField, ObjectId patientId, string? timeZoneId, string connectionId, GroupedObservation lastObsInGroup)

Parameters

groupedField GroupedField

The grouped field criteria used to locate or create the matching subscription.

patientId ObjectId

The identifier of the patient whose grouped observation is being subscribed to.

timeZoneId string

The optional time zone identifier applied to the new subscription when one is created.

connectionId string

The unique identifier of the client connection being registered.

lastObsInGroup GroupedObservation

The most recent observation in the group, used to initialize a new subscription.

GetGrouped()

Returns a thread-safe snapshot of the grouped subscribers as a new list. The internal collection is locked during the copy to ensure consistency and prevent concurrent modification.

public List<WsSubscriberGrouped> GetGrouped()

Returns

List<WsSubscriberGrouped>

A new List<T> containing a copy of the grouped subscribers.

RemoveGroupedObsByPatientId(string)

Removes all grouped observations associated with the specified patient identifier from the subscriber collection in a thread-safe manner.

public void RemoveGroupedObsByPatientId(string patientId)

Parameters

patientId string

The string representation of the patient identifier used to locate and remove the matching grouped observations.

RemoveWsSubscriberByLocation(string, PatientLocation?)

Check if what clients dont need to get updated with new grouped observations and remove them diference between section and box if location is updated doesn't matter if is section or box BoxSubscribers don't need to get updated otherwise SectionSubscribers may still need to get updated

public void RemoveWsSubscriberByLocation(string patientId, PatientLocation? newLocation)

Parameters

patientId string

objectId on db for Patient

newLocation PatientLocation

RemoveWsSubscriberPatientIdAndWsId(string, string)

Removes the specified WebSocket subscriber ID from all subscriber groups associated with the given patient ID in a thread-safe manner, and checks whether any resulting group is now empty for further cleanup.

public void RemoveWsSubscriberPatientIdAndWsId(string patientId, string wsIdToRemove)

Parameters

patientId string

The patient identifier used to locate the subscriber groups to update.

wsIdToRemove string

The WebSocket subscriber ID to remove from the matching subscriber and group collections.

UpdateLastGroupedObsInGroup(string, GroupedObservation)

Updates the last grouped observation in the subscriber group identified by the specified hash code. Performs a thread-safe lookup; if no matching subscriber group is found, the operation is silently skipped.

public void UpdateLastGroupedObsInGroup(string wsgHashCode, GroupedObservation newGroupedObservation)

Parameters

wsgHashCode string

The hash code used to identify the target subscriber group whose last grouped observation should be updated.

newGroupedObservation GroupedObservation

The new GroupedObservation to set as the last grouped observation in the matched group.