/ApplicationStartedHandler.cs Secret
Last active
September 30, 2020 18:11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Morodar.TS3.Service.Handlers.Notification | |
{ | |
// Code simplified for demonstration | |
public class ApplicationStartedHandler : INotificationHandler<ApplicationStartedNotification> | |
{ | |
private readonly IRepository<ServerConfig> serverConfigRepository; | |
private readonly ITeamSpeakClientRepository teamSpeakClientRepository; | |
public ApplicationStartedHandler( | |
IRepository<ServerConfig> serverConfigRepository, | |
ITeamSpeakClientRepository teamSpeakClientRepository) | |
{ | |
this.serverConfigRepository = serverConfigRepository; | |
this.teamSpeakClientRepository = teamSpeakClientRepository; | |
} | |
public async Task Handle( | |
ApplicationStartedNotification notification, | |
CancellationToken cancellationToken) | |
{ | |
var allConfigs = await serverConfigRepository.GetAllAsync(); | |
await Task.WhenAll( | |
allConfigs.Select( | |
config => teamSpeakClientRepository.CreateClientAsync(config))); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment