2023-11-21 21:37:50 +01:00
|
|
|
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
2023-11-20 19:58:30 +01:00
|
|
|
|
2023-08-12 23:02:59 +02:00
|
|
|
using MassTransit;
|
2023-11-19 17:07:28 +01:00
|
|
|
using Server.Packets;
|
|
|
|
using Server.Services;
|
|
|
|
|
|
|
|
namespace Server.Consumers;
|
2023-08-09 16:23:41 +02:00
|
|
|
|
2023-08-09 20:14:14 +02:00
|
|
|
public class PacketConsumer : IConsumer<RawPacket>
|
2023-08-09 16:23:41 +02:00
|
|
|
{
|
2023-10-27 19:47:17 +02:00
|
|
|
private readonly PacketDistributorService _distributorService;
|
2023-08-09 16:23:41 +02:00
|
|
|
|
2023-11-19 17:07:28 +01:00
|
|
|
public PacketConsumer(PacketDistributorService distributorService)
|
|
|
|
{
|
|
|
|
_distributorService = distributorService;
|
|
|
|
}
|
2023-08-09 16:23:41 +02:00
|
|
|
|
2023-08-09 20:14:14 +02:00
|
|
|
public Task Consume(ConsumeContext<RawPacket> context)
|
2023-08-09 16:23:41 +02:00
|
|
|
{
|
2023-11-19 17:07:28 +01:00
|
|
|
_distributorService.AddPacket(context.Message);
|
2023-08-09 20:14:14 +02:00
|
|
|
return Task.CompletedTask;
|
2023-08-09 16:23:41 +02:00
|
|
|
}
|
2023-08-11 11:31:30 +02:00
|
|
|
}
|