Table of Contents

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

discordClient DiscordSocketClient

The Discord socket client.

dbContextFactory NpgsqlDbContextFactory

Factory for creating database contexts.

logger ILogger<ChatPollingService>

Logger instance.

configuration IConfiguration

Application configuration.

dynamicChannelManager DynamicChannelManagerService

Service managing dynamic Discord channels.

bridgeBanService BridgeBanService
accountLinkingService AccountLinkingService
botConfigService BotConfigurationService
relayPolicy ChatRelayPolicy

Allowlist 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

cancellationToken CancellationToken

Indicates that the start process has been aborted.

Returns

Task

A Task that represents the asynchronous Start operation.

StopAsync(CancellationToken)

Triggered when the application host is performing a graceful shutdown.

public Task StopAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Indicates that the shutdown process should no longer be graceful.

Returns

Task

A Task that represents the asynchronous Stop operation.