server-master/srcs/PhoenixLib.Messaging/Internal/GenericMessagePublisher.cs
2026-02-10 18:21:30 +01:00

23 lines
No EOL
650 B
C#

using System.Threading;
using System.Threading.Tasks;
using PhoenixLib.ServiceBus.MQTT;
namespace PhoenixLib.ServiceBus
{
internal sealed class GenericMessagePublisher<T> : IMessagePublisher<T> where T : IMessage
{
private readonly IMessagingService _publisher;
public GenericMessagePublisher(IMessagingService publisher) => _publisher = publisher;
public async Task PublishAsync(T notification, CancellationToken token = default)
{
if (token.IsCancellationRequested)
{
return;
}
await _publisher.SendAsync(notification);
}
}
}