From e051007ecdb3097bc9942fd9db369101a9568a0d Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 23 Dec 2023 08:54:55 +0100 Subject: Basic test --- ModAS.Server/Services/UserContextService.cs | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ModAS.Server/Services/UserContextService.cs (limited to 'ModAS.Server/Services/UserContextService.cs') diff --git a/ModAS.Server/Services/UserContextService.cs b/ModAS.Server/Services/UserContextService.cs new file mode 100644 index 0000000..23969cc --- /dev/null +++ b/ModAS.Server/Services/UserContextService.cs @@ -0,0 +1,32 @@ +// using System.Collections.Concurrent; +// using System.Text.Json.Serialization; +// using ArcaneLibs.Extensions; +// using LibMatrix.Homeservers; +// using MxApiExtensions.Services; +// +// namespace ModAS.Server.Services; +// +// public class UserContextService(ModASConfiguration config, AuthenticatedHomeserverProviderService hsProvider) { +// internal static ConcurrentDictionary UserContextStore { get; set; } = new(); +// public readonly int SessionCount = UserContextStore.Count; +// +// public class UserContext { +// [JsonIgnore] +// public AuthenticatedHomeserverGeneric Homeserver { get; set; } +// } +// +// private readonly SemaphoreSlim _getUserContextSemaphore = new SemaphoreSlim(1, 1); +// public async Task GetCurrentUserContext() { +// var hs = await hsProvider.GetHomeserver(); +// // await _getUserContextSemaphore.WaitAsync(); +// var ucs = await UserContextStore.GetOrCreateAsync($"{hs.WhoAmI.UserId}/{hs.WhoAmI.DeviceId}/{hs.ServerName}:{hs.AccessToken}", async x => { +// var userContext = new UserContext() { +// Homeserver = hs +// }; +// +// return userContext; +// }, _getUserContextSemaphore); +// // _getUserContextSemaphore.Release(); +// return ucs; +// } +// } -- cgit 1.5.1