mirror of
				https://github.com/snltty/linker.git
				synced 2025-10-31 20:43:00 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using cmonitor.config;
 | |
| using cmonitor.plugins.relay.messenger;
 | |
| using cmonitor.plugins.relay.transport;
 | |
| using cmonitor.startup;
 | |
| using Microsoft.Extensions.DependencyInjection;
 | |
| using System.Reflection;
 | |
| 
 | |
| namespace cmonitor.plugins.relay
 | |
| {
 | |
|     public sealed class RelayStartup : IStartup
 | |
|     {
 | |
|         public StartupLevel Level => StartupLevel.Normal;
 | |
|         public void AddClient(ServiceCollection serviceCollection, Config config, Assembly[] assemblies)
 | |
|         {
 | |
|             serviceCollection.AddSingleton<RelayApiController>();
 | |
|             serviceCollection.AddSingleton<RelayClientMessenger>();
 | |
|             serviceCollection.AddSingleton<TransportSelfHost>();
 | |
|             serviceCollection.AddSingleton<RelayTransfer>();
 | |
| 
 | |
| 
 | |
|             if (config.Data.Client.Relay.Servers.Length == 0)
 | |
|             {
 | |
|                 config.Data.Client.Relay.Servers = new RelayCompactInfo[]
 | |
|                 {
 | |
|                      new RelayCompactInfo{ Name="self", Disabled = false, Host = config.Data.Client.Server }
 | |
|                 };
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         public void AddServer(ServiceCollection serviceCollection, Config config, Assembly[] assemblies)
 | |
|         {
 | |
|             serviceCollection.AddSingleton<RelayServerMessenger>();
 | |
|         }
 | |
| 
 | |
|         public void UseClient(ServiceProvider serviceProvider, Config config, Assembly[] assemblies)
 | |
|         {
 | |
|             RelayTransfer relayTransfer = serviceProvider.GetService<RelayTransfer>();
 | |
|             relayTransfer.Load(assemblies);
 | |
|         }
 | |
| 
 | |
|         public void UseServer(ServiceProvider serviceProvider, Config config, Assembly[] assemblies)
 | |
|         {
 | |
|         }
 | |
|     }
 | |
| }
 | 
