Creado apartir del commit b888de6c92056de294456f581a56e25e734d4ab7 de develop
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using adas_core.Application.Services.Interfaces;
|
||||
using adas_core.Application.Subscriptions;
|
||||
using MongoDB.Bson;
|
||||
|
||||
namespace adas_core.Application.Services;
|
||||
|
||||
public class SubscribersService : ISubscribersService
|
||||
{
|
||||
private readonly List<WsSubscriber> _subscribers = [];
|
||||
|
||||
|
||||
public List<WsSubscriber> GetSubscribers()
|
||||
{
|
||||
lock (_subscribers)
|
||||
{
|
||||
return _subscribers.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public WsSubscriber? GetById(string contextConnectionId)
|
||||
{
|
||||
lock (_subscribers)
|
||||
{
|
||||
return _subscribers.FirstOrDefault(s => s.Id == contextConnectionId);
|
||||
}
|
||||
}
|
||||
|
||||
public List<WsSubscriber> GetByPocId(ObjectId pocId)
|
||||
{
|
||||
lock (_subscribers)
|
||||
{
|
||||
return _subscribers.Where(s => s.LocationIds.Contains(pocId)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public int RemoveConnectionById(string contextConnectionId)
|
||||
{
|
||||
lock (_subscribers)
|
||||
{
|
||||
return _subscribers.RemoveAll(s => s.Id == contextConnectionId);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddSubscriber(WsSubscriber subscriber)
|
||||
{
|
||||
lock (_subscribers)
|
||||
{
|
||||
_subscribers.Add(subscriber);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user