This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#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<string> DependsOn => Array.Empty<string>();
|
||||
|
||||
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<string> GetSessionSummaries()
|
||||
{
|
||||
return Service.Sessions.Values
|
||||
.OrderBy(session => session.SessionId)
|
||||
.Select(session => $"session={session.SessionId}, remote={session.RemoteAddress}, peer={session.PeerKind}")
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user