Started reimplementing server feature because we use a new project structure now. This is way cleaner than the last implementation
This commit is contained in:
30
Moonlight/Features/Servers/Services/NodeService.cs
Normal file
30
Moonlight/Features/Servers/Services/NodeService.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Moonlight.Features.Servers.Entities;
|
||||
using Moonlight.Features.Servers.Models.Abstractions;
|
||||
|
||||
namespace Moonlight.Features.Servers.Services;
|
||||
|
||||
public class NodeService
|
||||
{
|
||||
private readonly Dictionary<int, NodeMeta> MetaCache = new();
|
||||
|
||||
public Task UpdateMeta(ServerNode node, Action<NodeMeta> metaAction)
|
||||
{
|
||||
lock (MetaCache)
|
||||
{
|
||||
NodeMeta? meta = null;
|
||||
|
||||
if (MetaCache.ContainsKey(node.Id))
|
||||
meta = MetaCache[node.Id];
|
||||
|
||||
if (meta == null)
|
||||
{
|
||||
meta = new();
|
||||
MetaCache.Add(node.Id, meta);
|
||||
}
|
||||
|
||||
metaAction.Invoke(meta);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user