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
cacheServiceICacheServicegroupedObservationServiceIGroupedObservationServiceloggerILogger<SubscriberGroupedService>clientMessageServiceLazy<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
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
wsSubscriberGroupedWsSubscriberGroupedThe 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
wsSubscriberGroupedWsSubscriberGroupedObject with properties to generate new grouped observations, clients using those grouped obsercations and the generated list of grouped observations
Returns
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
groupedFieldGroupedFieldThe grouped field criteria used to locate or create the matching subscription.
patientIdObjectIdThe identifier of the patient whose grouped observation is being subscribed to.
timeZoneIdstringThe optional time zone identifier applied to the new subscription when one is created.
connectionIdstringThe unique identifier of the client connection being registered.
lastObsInGroupGroupedObservationThe 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
patientIdstringThe 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
patientIdstringobjectId on db for Patient
newLocationPatientLocation
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
patientIdstringThe patient identifier used to locate the subscriber groups to update.
wsIdToRemovestringThe 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
wsgHashCodestringThe hash code used to identify the target subscriber group whose last grouped observation should be updated.
newGroupedObservationGroupedObservationThe new GroupedObservation to set as the last grouped observation in the matched group.