blob: 23969cccb107e80664f2ae1d7d3f7b5e8eed87a2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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<string, UserContext> 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<UserContext> 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;
// }
// }
|