// SPDX-License-Identifier: AGPL-3.0-only
/**
* Digital Voice Modem - Desktop Dispatch Console
* AGPLv3 Open Source. Use is subject to license terms.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* @package DVM / Desktop Dispatch Console
* @license AGPLv3 License (https://opensource.org/licenses/AGPL-3.0)
*
* Copyright (C) 2025 Caleb, K4PHP
*
*/
namespace dvmconsole
{
///
///
///
public class FneSystemManager
{
private readonly Dictionary peerHandlers;
/*
** Methods
*/
///
/// Creates an instance of class.
///
public FneSystemManager()
{
peerHandlers = new Dictionary();
}
///
/// Create a new for a new system
///
///
public void AddFneSystem(string systemId, Codeplug.System system, MainWindow mainWindow)
{
if (!peerHandlers.ContainsKey(systemId))
peerHandlers[systemId] = new PeerSystem(mainWindow, system);
}
///
/// Return a by looking up a systemid
///
///
///
///
public PeerSystem GetFneSystem(string systemId)
{
if (peerHandlers.TryGetValue(systemId, out var handler))
return handler;
throw new KeyNotFoundException($"WebSocketHandler for system '{systemId}' not found.");
}
///
/// Delete a by system id
///
///
public void RemoveFneSystem(string systemId)
{
if (peerHandlers.TryGetValue(systemId, out var handler))
{
handler.peer.Stop();
peerHandlers.Remove(systemId);
}
}
///
/// Check if the manager has a handler
///
///
///
public bool HasFneSystem(string systemId)
{
return peerHandlers.ContainsKey(systemId);
}
///
/// Cleanup
///
public void ClearAll()
{
foreach (var handler in peerHandlers.Values)
handler.peer.Stop();
peerHandlers.Clear();
}
} // public class FneSystemManager
} // namespace dvmconsole