protected override void Run() { this.Logger.LogInfo("Running Music Server, Enter keys to publish events..."); while (true) { // Read single keystroke. ConsoleKeyInfo key = Console.ReadKey(); string input = key.Key.ToString(); if (input.Equals("q", StringComparison.OrdinalIgnoreCase)) { // Quit running the server. break; } this.Logger.LogDebug($"The keystroke was {input}"); // Decide which event to publish. if (input == this.Config.SongPauseKey) { this.Logger.LogInfo($"Sending Song Paused Event..."); this.Publisher.Publish(new SongPausedEvent()); } else { this.Logger.LogInfo($"Sending Song Info Event..."); SongInfoEvent @event = new SongInfoEvent(10, "Battle Theme", "Game Freak"); this.Publisher.Publish(@event); } } }
void OnSongInfoChanged(SongInfoEvent @event) { this.TotalEventsReceived += 1; this.Logger.LogInfo($"Song Info: Id = {@event.Id}, Title = '{@event.Title}', Artist = '{@event.Artist}'"); this.Logger.LogWarning($"Total Events Received: {this.TotalEventsReceived}"); }