about summary refs log tree commit diff
path: root/ModerationClient/Services/ClientContainer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ModerationClient/Services/ClientContainer.cs')
-rw-r--r--ModerationClient/Services/ClientContainer.cs34
1 files changed, 33 insertions, 1 deletions
diff --git a/ModerationClient/Services/ClientContainer.cs b/ModerationClient/Services/ClientContainer.cs

index fa3abef..957e3cc 100644 --- a/ModerationClient/Services/ClientContainer.cs +++ b/ModerationClient/Services/ClientContainer.cs
@@ -1,8 +1,40 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; + namespace ModerationClient.Services; public class ClientContainer { - public ClientContainer(MatrixAuthenticationService authService, CommandLineConfiguration cfg) + private readonly ILogger<ClientContainer> _logger; + private readonly MatrixAuthenticationService _authService; + private readonly CommandLineConfiguration _cfg; + + public ClientContainer(ILogger<ClientContainer> logger, MatrixAuthenticationService authService, CommandLineConfiguration cfg) { + _logger = logger; + _authService = authService; + _cfg = cfg; + } + + private bool _isRunning = false; + + public void EnsureRunning() + { + if (_isRunning) return; + _isRunning = true; + _ = Task.Run(Run).ContinueWith(t => { + if (t.IsFaulted) + { + _logger.LogError(t.Exception, "Error in client container task"); + } + return _isRunning = false; + }); + } + + private async Task Run() { + Console.WriteLine("Running client view model loop..."); + ArgumentNullException.ThrowIfNull(_authService.Homeserver, nameof(_authService.Homeserver)); } } \ No newline at end of file