2025-02-17 12:46:40 +03:00
|
|
|
using mROA.Abstract;
|
|
|
|
|
|
|
|
|
|
namespace mROA.Implementation.Backend;
|
|
|
|
|
|
|
|
|
|
public class ConntectionHub : IConnectionHub
|
|
|
|
|
{
|
2025-02-17 16:52:58 +03:00
|
|
|
private readonly Dictionary<int, INextGenerationInteractionModule> _connections = new();
|
|
|
|
|
private ISerializationToolkit _serializationToolkit;
|
|
|
|
|
|
|
|
|
|
public void RegisterInteraction(INextGenerationInteractionModule interaction)
|
2025-02-17 12:46:40 +03:00
|
|
|
{
|
2025-02-17 16:52:58 +03:00
|
|
|
|
|
|
|
|
var module = new RepresentationModule();
|
|
|
|
|
module.Inject(_serializationToolkit);
|
|
|
|
|
module.Inject(interaction);
|
|
|
|
|
OnConnected?.Invoke(module);
|
2025-02-17 12:46:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public INextGenerationInteractionModule GetInteracion(int id)
|
|
|
|
|
{
|
2025-02-17 16:52:58 +03:00
|
|
|
return _connections!.GetValueOrDefault(id, null) ?? throw new Exception("No connection found");
|
2025-02-17 12:46:40 +03:00
|
|
|
}
|
|
|
|
|
|
2025-02-17 16:52:58 +03:00
|
|
|
public event ConnectionHandler? OnConnected;
|
2025-02-17 12:46:40 +03:00
|
|
|
public event DisconnectionHandler? OnDisconnected;
|
|
|
|
|
}
|