public IActionResult Publish() { DemoEvent demo = new DemoEvent($"event time {DateTime.Now}"); _dispatcher.Broadcast(demo); return(Ok(DateTime.Now)); }
private void _timer_Elapsed(object sender, ElapsedEventArgs e) { _ticks++; //Всякий раз, когда таймер тикает, мы генерим свое событие, но не простое, а несущее информацию о количестве тиков (а могло бы нести и более сложные данные) DemoEvent?.Invoke(this, new DemoEventAgrs { Ticks = _ticks }); }
static async Task Main() { var endpointConfiguration = new EndpointConfiguration("endpointA"); endpointConfiguration.EnableInstallers(); endpointConfiguration.UsePersistence <InMemoryPersistence>(); endpointConfiguration.SendFailedMessagesTo("error"); var routingConfig = endpointConfiguration.UseTransport <MsmqTransport>().Routing(); routingConfig.InstanceMappingFile().FilePath("instance-mapping.xml"); routingConfig.UseFileBasedRouting(); var endpoint = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); Console.WriteLine("Press [c] to send a command. Press [e] to publish an event. Press [Esc] to quit."); while (true) { var key = Console.ReadKey(); if (key.Key == ConsoleKey.Escape) { break; } if (key.Key == ConsoleKey.C) { var commandId = Guid.NewGuid(); var demoCommand = new DemoCommand { CommandId = commandId }; await endpoint.Send(demoCommand) .ConfigureAwait(false); Console.WriteLine(); Console.WriteLine("Sent command with id: " + commandId); } if (key.Key == ConsoleKey.E) { var eventId = Guid.NewGuid(); var demoEvent = new DemoEvent { EventId = eventId }; await endpoint.Publish(demoEvent) .ConfigureAwait(false); Console.WriteLine(); Console.WriteLine("Sent event with id: " + eventId); } } await endpoint.Stop() .ConfigureAwait(false); }
public async Task <DemoEvent> CreateEvent([FromBody] DemoEvent viewModel) => await _mediator.Send(new CreateEventCommand(viewModel.Start, viewModel.End));
public ChangeGameState(DemoEvent demoEvent) { Reason = ChangeGameStateReason.DemoEvent; Value = (float)demoEvent; }