// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License. using System.Reflection; namespace Rai.PacketMediator; public class PacketDistributorService : Microsoft.Extensions.Hosting.IHostedService where TPacketIdEnum : Enum { private readonly PacketDistributor _packetDistributor; public PacketDistributorService(IServiceProvider serviceProvider, Assembly[] sourcesContainingPackets) { _packetDistributor = new PacketDistributor(serviceProvider, sourcesContainingPackets); } public Task StartAsync(CancellationToken cancellationToken) { return _packetDistributor.DequeueRawPacketAsync(cancellationToken); } public Task AddPacketAsync(byte[] packetData, TPacketIdEnum operationCode, TSession session) { return this._packetDistributor.AddPacketAsync(packetData, operationCode, session); } public Task StopAsync(CancellationToken cancellationToken) { return Task.CompletedTask; } }