Added channel saving. Fixed channel loading. Added policy store to channels.
This commit is contained in:
@ -4,13 +4,15 @@ namespace HermesSocketServer.Services
|
||||
{
|
||||
public class DatabaseService : BackgroundService
|
||||
{
|
||||
private readonly ChannelManager _channels;
|
||||
private readonly VoiceStore _voices;
|
||||
private readonly UserStore _users;
|
||||
private readonly ServerConfiguration _configuration;
|
||||
private readonly Serilog.ILogger _logger;
|
||||
|
||||
public DatabaseService(VoiceStore voices, UserStore users, ServerConfiguration configuration, Serilog.ILogger logger)
|
||||
public DatabaseService(ChannelManager channels, VoiceStore voices, UserStore users, ServerConfiguration configuration, Serilog.ILogger logger)
|
||||
{
|
||||
_channels = channels;
|
||||
_voices = voices;
|
||||
_users = users;
|
||||
_configuration = configuration;
|
||||
@ -26,14 +28,16 @@ namespace HermesSocketServer.Services
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var tasks = new List<Task>();
|
||||
await Task.Delay(TimeSpan.FromSeconds(_configuration.Database.SaveDelayInSeconds));
|
||||
|
||||
while (true)
|
||||
{
|
||||
tasks.Add(_voices.Save());
|
||||
tasks.Add(_users.Save());
|
||||
tasks.Add(Task.Delay(TimeSpan.FromSeconds(_configuration.Database.SaveDelayInSeconds)));
|
||||
await Task.WhenAll(tasks);
|
||||
await Task.WhenAll([
|
||||
_voices.Save(),
|
||||
_users.Save(),
|
||||
_channels.Save(),
|
||||
Task.Delay(TimeSpan.FromSeconds(_configuration.Database.SaveDelayInSeconds)),
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user