Cleaned up request acks. Added internal service bus for internal messaging.
This commit is contained in:
@ -5,6 +5,8 @@ using HermesSocketLibrary.Requests.Messages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using org.mariuszgromada.math.mxparser;
|
||||
using Serilog;
|
||||
using TwitchChatTTS.Bus;
|
||||
using TwitchChatTTS.Bus.Data;
|
||||
using TwitchChatTTS.Hermes.Socket;
|
||||
using TwitchChatTTS.OBS.Socket;
|
||||
using TwitchChatTTS.OBS.Socket.Data;
|
||||
@ -14,6 +16,7 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
public class RedemptionManager : IRedemptionManager
|
||||
{
|
||||
private readonly IDictionary<string, IList<RedeemableAction>> _store;
|
||||
private readonly ServiceBusCentral _bus;
|
||||
private readonly User _user;
|
||||
private readonly OBSSocketClient _obs;
|
||||
private readonly HermesSocketClient _hermes;
|
||||
@ -25,6 +28,7 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
|
||||
|
||||
public RedemptionManager(
|
||||
ServiceBusCentral bus,
|
||||
User user,
|
||||
[FromKeyedServices("obs")] SocketClient<WebSocketMessage> obs,
|
||||
[FromKeyedServices("hermes")] SocketClient<WebSocketMessage> hermes,
|
||||
@ -33,6 +37,7 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
ILogger logger)
|
||||
{
|
||||
_store = new Dictionary<string, IList<RedeemableAction>>();
|
||||
_bus = bus;
|
||||
_user = user;
|
||||
_obs = (obs as OBSSocketClient)!;
|
||||
_hermes = (hermes as HermesSocketClient)!;
|
||||
@ -41,6 +46,12 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
||||
_logger = logger;
|
||||
_random = new Random();
|
||||
_isReady = false;
|
||||
|
||||
var topic = _bus.GetTopic("redemptions_initiation");
|
||||
topic.Subscribe(new ServiceBusObserver(data => {
|
||||
if (data.Value is RedemptionInitiation obj)
|
||||
Initialize(obj.Redemptions, obj.Actions);
|
||||
}, _logger));
|
||||
}
|
||||
|
||||
private void Add(string twitchRedemptionId, RedeemableAction action)
|
||||
|
Reference in New Issue
Block a user