Class ChatPollingService
- Namespace
- FishMMO.DiscordBot.Services
- Assembly
- FishMMO-DiscordBot.dll
Background service that polls the game database for new chat messages and forwards them to the appropriate Discord channels. Uses a reentrancy guard to prevent overlapping polls.
public class ChatPollingService : IHostedService, IDisposable
- Inheritance
-
ChatPollingService
- Implements
- Inherited Members
Constructors
ChatPollingService(DiscordSocketClient, NpgsqlDbContextFactory, ILogger<ChatPollingService>, IConfiguration, DynamicChannelManagerService, BridgeBanService, AccountLinkingService, BotConfigurationService, ChatRelayPolicy)
Initializes a new instance of the ChatPollingService class.
public ChatPollingService(DiscordSocketClient discordClient, NpgsqlDbContextFactory dbContextFactory, ILogger<ChatPollingService> logger, IConfiguration configuration, DynamicChannelManagerService dynamicChannelManager, BridgeBanService bridgeBanService, AccountLinkingService accountLinkingService, BotConfigurationService botConfigService, ChatRelayPolicy relayPolicy)
Parameters
discordClientDiscordSocketClientThe Discord socket client.
dbContextFactoryNpgsqlDbContextFactoryFactory for creating database contexts.
loggerILogger<ChatPollingService>Logger instance.
configurationIConfigurationApplication configuration.
dynamicChannelManagerDynamicChannelManagerServiceService managing dynamic Discord channels.
bridgeBanServiceBridgeBanServiceaccountLinkingServiceAccountLinkingServicebotConfigServiceBotConfigurationServicerelayPolicyChatRelayPolicyAllowlist deciding which game channels may reach Discord.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
StartAsync(CancellationToken)
Triggered when the application host is ready to start the service.
public Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenIndicates that the start process has been aborted.
Returns
StopAsync(CancellationToken)
Triggered when the application host is performing a graceful shutdown.
public Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenIndicates that the shutdown process should no longer be graceful.