#nullable enable using System; using System.Linq; using Cysharp.Threading.Tasks; using ShrinkApp; namespace ShrinkNetwork.Integration.App { [ShrinkAppModuleInstaller] [Obsolete("ClassicHost compatibility only. ContextLoader projects should use ShrinkNetworkAppComponent from a composition root.")] public sealed class ShrinkNetworkAppInstaller : IShrinkAppModuleInstaller { public string ModuleId => "shrink.network"; public int Order => -1400; public System.Collections.Generic.IReadOnlyList DependsOn => Array.Empty(); public void RegisterServices(ShrinkAppContext context) { context.Services.Register(new ShrinkNetworkAppService(ShrinkNetworkRuntime.Default)); } public UniTask InitializeAsync(ShrinkAppContext context) { return UniTask.CompletedTask; } } public sealed class ShrinkNetworkAppService { public ShrinkNetworkAppService(ShrinkNetworkService service) { Service = service ?? throw new ArgumentNullException(nameof(service)); } public ShrinkNetworkService Service { get; } public ShrinkNetworkServiceDiagnosticsSnapshot GetDiagnosticsSnapshot() => Service.GetDiagnosticsSnapshot(); public System.Collections.Generic.IReadOnlyList GetSessionSummaries() { return Service.Sessions.Values .OrderBy(session => session.SessionId) .Select(session => $"session={session.SessionId}, remote={session.RemoteAddress}, peer={session.PeerKind}") .ToArray(); } } }