2025-05-06 23:28:00 +03:00
|
|
|
using System;
|
2025-03-10 16:35:56 +03:00
|
|
|
using System.Net;
|
2025-02-05 18:04:35 +03:00
|
|
|
using Example.Backend;
|
2025-07-03 17:37:25 +03:00
|
|
|
using Example.Shared;
|
2025-02-07 16:53:12 +03:00
|
|
|
using mROA.Abstract;
|
2025-02-27 00:12:52 +03:00
|
|
|
using mROA.Cbor;
|
2025-02-05 15:08:38 +03:00
|
|
|
using mROA.Codegen;
|
|
|
|
|
using mROA.Implementation;
|
2025-02-07 16:53:12 +03:00
|
|
|
using mROA.Implementation.Backend;
|
2025-07-11 23:18:24 +03:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
2025-07-19 17:18:46 +03:00
|
|
|
using Microsoft.Extensions.Logging;
|
2025-02-05 15:08:38 +03:00
|
|
|
|
2025-02-20 16:10:09 +03:00
|
|
|
class Program
|
2025-02-18 17:45:01 +03:00
|
|
|
{
|
2025-02-20 16:10:09 +03:00
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2025-07-11 23:18:24 +03:00
|
|
|
var builder = Host.CreateApplicationBuilder();
|
2025-07-19 17:18:46 +03:00
|
|
|
builder.Services.AddLogging(l => l.AddConsole());
|
2025-07-11 23:18:24 +03:00
|
|
|
builder.Services.AddSingleton<IContextualSerializationToolKit, CborSerializationToolkit>();
|
|
|
|
|
builder.Services.AddSingleton<IIdentityGenerator, BackendIdentityGenerator>();
|
|
|
|
|
builder.Services.AddSingleton<IGatewayModule, NetworkGatewayModule>();
|
|
|
|
|
builder.Services.AddSingleton<IUntrustedGateway, UdpGateway>();
|
|
|
|
|
builder.Services.AddSingleton<IConnectionHub, ConnectionHub>();
|
2025-08-16 12:14:03 +03:00
|
|
|
|
2025-07-11 23:18:24 +03:00
|
|
|
builder.Services.AddOptions();
|
2025-06-30 15:45:41 +03:00
|
|
|
var listening = new IPEndPoint(IPAddress.Any, 4567);
|
2025-07-11 23:18:24 +03:00
|
|
|
builder.Services.Configure<GatewayOptions>(options => options.Endpoint = listening);
|
2025-08-09 13:03:20 +03:00
|
|
|
builder.Services.AddSingleton<IDistributionModule, ExtractorFirstDistributionModule>();
|
2025-08-16 19:51:35 +03:00
|
|
|
builder.Services.Configure<SerializationBufferOffset>(options => options.Offset = 0);
|
2025-07-11 23:18:24 +03:00
|
|
|
builder.Services.AddSingleton<HubRequestExtractor>();
|
|
|
|
|
builder.Services.AddSingleton<IExecuteModule, BasicExecutionModule>();
|
|
|
|
|
builder.Services.AddSingleton<IRepresentationModuleProducer, CreativeRepresentationModuleProducer>();
|
|
|
|
|
builder.Services.AddSingleton<IInstanceRepository, RemoteInstanceRepository>();
|
|
|
|
|
builder.Services.AddSingleton<IRealStoreInstanceRepository>(provider => new MultiClientInstanceRepository(i =>
|
2025-02-20 16:10:09 +03:00
|
|
|
{
|
2025-07-11 23:18:24 +03:00
|
|
|
var producer = provider.GetService<IRepresentationModuleProducer>();
|
|
|
|
|
var repo = new InstanceRepository(producer);
|
2025-02-20 16:10:09 +03:00
|
|
|
repo.FillSingletons(typeof(PrinterFactory).Assembly);
|
2025-07-11 23:18:24 +03:00
|
|
|
|
2025-02-20 16:10:09 +03:00
|
|
|
return repo;
|
|
|
|
|
}));
|
2025-07-11 23:18:24 +03:00
|
|
|
|
|
|
|
|
builder.Services.AddSingleton<IMethodRepository>(p =>
|
|
|
|
|
{
|
|
|
|
|
var methodRepo = new CollectableMethodRepository();
|
|
|
|
|
methodRepo.AppendInvokers(new GeneratedInvokersCollection());
|
|
|
|
|
return methodRepo;
|
|
|
|
|
});
|
|
|
|
|
builder.Services.AddSingleton<ICallIndexProvider, GeneratedCallIndexProvider>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddSingleton<ICancellationRepository, CancellationRepository>();
|
|
|
|
|
|
2025-07-12 16:50:23 +03:00
|
|
|
var host = builder.Build();
|
2025-07-11 23:18:24 +03:00
|
|
|
//
|
2025-07-18 13:49:36 +03:00
|
|
|
new RemoteTypeBinder();
|
2025-07-11 23:18:24 +03:00
|
|
|
//
|
2025-08-16 12:14:03 +03:00
|
|
|
|
|
|
|
|
var contextualSerializationToolKit = host.Services.GetService<IContextualSerializationToolKit>();
|
|
|
|
|
contextualSerializationToolKit.Deserialize<NetworkMessage>(contextualSerializationToolKit.Serialize(new NetworkMessage(), null), null);
|
2025-07-18 13:49:36 +03:00
|
|
|
_ = host.Services.GetService<IUntrustedGateway>()!.Start();
|
|
|
|
|
var gateway = host.Services.GetService<IGatewayModule>();
|
|
|
|
|
gateway.Run();
|
2025-07-11 23:18:24 +03:00
|
|
|
|
2025-07-18 13:49:36 +03:00
|
|
|
Console.ReadLine();
|
2025-02-20 16:10:09 +03:00
|
|
|
}
|
|
|
|
|
}
|