using AyCode.Core.Loggers; using FruitBank.Common; using FruitBank.Common.Server.Services.Loggers; using FruitBank.Common.Server.Services.SignalRs; using Mango.Sandbox.EndPoints; using Microsoft.AspNetCore.Http.Connections; var builder = WebApplication.CreateBuilder(args); // =========================================== // === MINIMÁLIS KONFIGURÁCIÓ A SIGNALR HUB TESZTELÉSÉHEZ === // =========================================== Console.WriteLine("[SANDBOX] Starting minimal SignalR Hub test configuration..."); // =========================================== // === CORS === // =========================================== builder.Services.AddCors(options => { options.AddDefaultPolicy(policy => { policy.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); }); options.AddPolicy("SignalR", policy => { policy.SetIsOriginAllowed(_ => true).AllowAnyMethod().AllowAnyHeader().AllowCredentials(); }); }); // =========================================== // === DI VALIDÁCIÓ KIKAPCSOLÁSA === // =========================================== builder.Host.UseDefaultServiceProvider(options => { options.ValidateScopes = false; options.ValidateOnBuild = false; }); // =========================================== // === ALAPVETŐ INFRASTRUKTÚRA === // =========================================== builder.Services.AddHttpContextAccessor(); builder.Services.AddMemoryCache(); builder.Services.AddDistributedMemoryCache(); // IDistributedCache a Session-höz builder.Services.AddSession(); // =========================================== // === LOGGER - Csak ConsoleLogWriter a teszteléshez === // =========================================== builder.Services.AddScoped(); // =========================================== // === TESZT ENDPOINT === // =========================================== builder.Services.AddScoped(); // =========================================== // === SIGNALR KONFIGURÁCIÓ === // =========================================== builder.Services.AddSignalR(hubOptions => { hubOptions.EnableDetailedErrors = true; hubOptions.MaximumReceiveMessageSize = 30_000_000; hubOptions.KeepAliveInterval = TimeSpan.FromSeconds(FruitBankConstClient.SignalRKeepAliveIntervalSecond); hubOptions.ClientTimeoutInterval = TimeSpan.FromSeconds(FruitBankConstClient.SignarlRTimeoutIntervalSecond); hubOptions.StatefulReconnectBufferSize = 30_000_000; }); // =========================================== // === APP BUILD === // =========================================== var app = builder.Build(); app.UseCors("SignalR"); app.UseSession(); // =========================================== // === SIGNALR HUB REGISZTRÁCIÓ === // =========================================== var fruitBankHubEndPoint = $"/{FruitBankConstClient.DefaultHubName}"; // SANDBOX TESZT HUB - egyszerűsített, nincs Nop függőség app.MapHub(fruitBankHubEndPoint, options => { options.Transports = HttpTransportType.WebSockets; options.WebSockets.CloseTimeout = TimeSpan.FromSeconds(10); options.AllowStatefulReconnects = true; options.TransportMaxBufferSize = 30_000_000; options.ApplicationMaxBufferSize = 30_000_000; options.TransportSendTimeout = TimeSpan.FromSeconds(60); }); var loggerHubEndPoint = $"/{FruitBankConstClient.LoggerHubName}"; app.MapHub(loggerHubEndPoint, options => { options.AllowStatefulReconnects = false; }); app.MapGet("/", () => "SANDBOX is running!"); app.MapGet("/health", () => Results.Ok(new { status = "healthy", timestamp = DateTime.UtcNow })); // =========================================== // === CONSOLE OUTPUT === // =========================================== Console.Title = "[SB] - SignalR Test"; Console.WriteLine("==========================================="); Console.WriteLine(" FRUITBANK SANDBOX - SignalR Test Mode"); Console.WriteLine("==========================================="); Console.WriteLine($" Base URL: http://localhost:59579"); Console.WriteLine($" SignalR Hub: {fruitBankHubEndPoint}"); Console.WriteLine($" Logger Hub: {loggerHubEndPoint}"); Console.WriteLine("==========================================="); app.Run();