public QueueCommandResponse Any(QueueCommandRequest request) { using (var mqClient = TryResolve <ICommandQueueService>().CreateMessageQueueClient()) { mqClient.Publish(request); } return(new QueueCommandResponse() { Result = Result.Success() }); }
public static void VA_Init1(dynamic vaProxy) { _appHost = new AppHost(); _appHost.Init(); var listeners = _appHost.AppSettings.Get <List <string> >("config:listeners"); _appHost.Start(listeners); var commandQueueService = _appHost.Container.Resolve <ICommandQueueService>(); //wire handler for receiving a message from the message queue commandQueueService.RegisterHandler <QueueCommandRequest>(m => { QueueCommandRequest request = m.GetBody(); //loop thru all of the variables of each data type //and store them inside of voice attack request.SmallInts?.Each(v => vaProxy.SetSmallInt(v.Name, v.Value)); request.Ints?.Each(v => vaProxy.SetInt(v.Name, v.Value)); request.Strings?.Each(v => vaProxy.SetText(v.Name, v.Value)); request.Decimals?.Each(v => vaProxy.SetDecimal(v.Name, v.Value)); request.Booleans?.Each(v => vaProxy.SetBoolean(v.Name, v.Value)); request.Dates?.Each(v => vaProxy.SetDate(v.Name, v.Value)); //do not run the command if it does not exist if (!vaProxy.Command.Exists(request.CommandName)) { return(null); } //execute command. if you don't want it to execute the same command twice //you should set that up in the command advanced options vaProxy.Command.Execute(request.CommandName); return(null); }); commandQueueService.Start(); var alertQueueService = _appHost.Container.Resolve <IAlertQueueService>(); //wire handler for receiving a message from the message queue alertQueueService.RegisterHandler <AlertQueueRequest>(m => { AlertQueueRequest request = m.GetBody(); //do not run the command if it does not exist if (!vaProxy.Command.Exists(request.CommandName)) { return(null); } if (!string.IsNullOrWhiteSpace(request.User)) { vaProxy.SetText("TwitchAlertUser", request.User); } if (!string.IsNullOrWhiteSpace(request.Gifter)) { vaProxy.SetText("TwitchAlertGifter", request.Gifter); } if (request.Amount.HasValue) { vaProxy.SetDecimal("TwitchAlertAmount", request.Amount.Value); } //execute command. if you don't want it to execute the same command twice //you should set that up in the command advanced options vaProxy.Command.Execute(request.CommandName); if (request.Pause.HasValue) { System.Threading.Thread.Sleep(request.Pause.Value); } return(null); }); alertQueueService.Start(); }