Changed Collection to SynchronizedCollection
This commit is contained in:
parent
4d7b0e2b1e
commit
ef85dec657
@ -1,4 +1,3 @@
|
|||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using pacMan.Interfaces;
|
using pacMan.Interfaces;
|
||||||
@ -9,7 +8,7 @@ namespace pacMan.Services;
|
|||||||
public class WebSocketService : IWebSocketService
|
public class WebSocketService : IWebSocketService
|
||||||
{
|
{
|
||||||
private readonly ILogger<WebSocketService> _logger;
|
private readonly ILogger<WebSocketService> _logger;
|
||||||
private readonly BlockingCollection<WebSocket> _webSockets = new();
|
private readonly SynchronizedCollection<WebSocket> _webSockets = new();
|
||||||
|
|
||||||
public WebSocketService(ILogger<WebSocketService> logger)
|
public WebSocketService(ILogger<WebSocketService> logger)
|
||||||
{
|
{
|
||||||
@ -23,9 +22,9 @@ public class WebSocketService : IWebSocketService
|
|||||||
_logger.Log(LogLevel.Debug, "WebSocket added to list");
|
_logger.Log(LogLevel.Debug, "WebSocket added to list");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(WebSocket? webSocket)
|
public bool Remove(WebSocket webSocket)
|
||||||
{
|
{
|
||||||
var taken = _webSockets.TryTake(out webSocket);
|
var taken = _webSockets.Remove(webSocket);
|
||||||
_logger.Log(LogLevel.Debug, "WebSocket removed from list");
|
_logger.Log(LogLevel.Debug, "WebSocket removed from list");
|
||||||
return taken;
|
return taken;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user