Table of Contents

Class SubscribersService

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

Provides operations for managing subscribers by implementing the ISubscribersService contract. Acts as the concrete service layer responsible for subscriber-related functionality.

public class SubscribersService : ISubscribersService
Inheritance
SubscribersService
Implements
Inherited Members
Extension Methods

Methods

AddSubscriber(WsSubscriber)

Adds a WebSocket subscriber to the internal subscribers collection in a thread-safe manner. Ensures that concurrent calls to add subscribers are serialized to prevent race conditions.

public void AddSubscriber(WsSubscriber subscriber)

Parameters

subscriber WsSubscriber

The WebSocket subscriber to add to the collection.

GetById(string)

Retrieves a WebSocket subscriber by its connection identifier, returning null if no matching subscriber is found. Thread-safe access to the subscribers collection is ensured via locking.

public WsSubscriber? GetById(string contextConnectionId)

Parameters

contextConnectionId string

The unique connection identifier of the subscriber to look up.

Returns

WsSubscriber

The matching WsSubscriber if found; otherwise, null.

GetByPocId(ObjectId)

Retrieves all subscribers whose associated location identifiers include the specified point-of-contact identifier. Ensures thread-safe access to the underlying subscriber collection during the read operation.

public List<WsSubscriber> GetByPocId(ObjectId pocId)

Parameters

pocId ObjectId

The point-of-contact identifier used to match subscribers by their location list.

Returns

List<WsSubscriber>

A list of WsSubscriber instances that have pocId in their location identifiers; returns an empty list when no matches are found.

GetSubscribers()

Retrieves a thread-safe snapshot of the current list of WebSocket subscribers.

public List<WsSubscriber> GetSubscribers()

Returns

List<WsSubscriber>

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

RemoveConnectionById(string)

Removes all subscriber connections matching the specified connection identifier in a thread-safe manner.

public int RemoveConnectionById(string contextConnectionId)

Parameters

contextConnectionId string

The unique identifier of the connection to remove.

Returns

int

The number of connections that were removed from the subscribers list.