BackEndManagerBusinessLogic 1.0.0

dotnet add package BackEndManagerBusinessLogic --version 1.0.0                
NuGet\Install-Package BackEndManagerBusinessLogic -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BackEndManagerBusinessLogic" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BackEndManagerBusinessLogic --version 1.0.0                
#r "nuget: BackEndManagerBusinessLogic, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BackEndManagerBusinessLogic as a Cake Addin
#addin nuget:?package=BackEndManagerBusinessLogic&version=1.0.0

// Install BackEndManagerBusinessLogic as a Cake Tool
#tool nuget:?package=BackEndManagerBusinessLogic&version=1.0.0                

SIGNALR

Configurazione

program.cs

#region signalr
builder.Services.AddCors(options => options.AddPolicy(name: "enablecorsforclient", builder => {
    builder.AllowAnyMethod()
    .AllowAnyHeader()
    .AllowCredentials()
    .WithOrigins("http://localhost:5051")
    .SetIsOriginAllowed((host) => true);
}));
builder.Services.AddScoped<NotificationHub>();
builder.Services.AddSignalR().AddHubOptions<NotificationHub>(options => {
    options.EnableDetailedErrors = true;
});
builder.Services.AddSingleton<INotificationService, NotificationService>();
builder.Services.AddTransient<yourBusinessLogic>();

var app = builder.Build();

app.UseStaticFiles();
#region signalr
app.UseCors("enablecorsforclient");
app.MapHub<NotificationHub>("/NotificationHub");
#endregion
  1. spiegazione program.cs::
    • (AddCors) Aggiungere AdCors se i client si trovano su altro host.
    • (AddScoped) Aggiunge l' Hub tipizzato.
    • (AddSignalR) Aggiunge il servizio signalR Microsoft.AspNetCore.SignalR ( usare Redis su sistemi distribuiti )
    • (Single-responsibility principle) Aggiunge l' interfaccia per separare l' uso di Hub dalla business logic
    • (business logic) Aggiunge la tua business logic

Codice Javascript

"use strict";

const opts = {
    skipNegotiation: true,
    transport: signalR.HttpTransportType.WebSockets
};
var connection = new signalR.HubConnectionBuilder().withUrl("/NotificationHub", opts)
    .configureLogging(signalR.LogLevel.Debug) 
    .withAutomaticReconnect([...Array(10)].map((_, i) => i ? 5000 : 0))
    .build();


connection.error
connection.on("SendMessage", wsgotdata );
function wsgotdata(d) {
    var li = document.createElement("li");
    document.getElementById("messagesList").appendChild(li);
    li.textContent = `Notifica : ${d.notificationType} : Sport ${d.message.sport} : Cat: ${d.message.category} : tournament: ${d.message.tournament}`;
    li = document.createElement("li");
    document.getElementById("messagesList").appendChild(li);
    li.textContent = `content: ${d.message.additionalInfo}`;
    console.log(d);
}

connection.start().then(function () {
    document.getElementById("sendButton").disabled = false;
}).catch(function (err) {
    return console.error(err.toString());
});

document.getElementById("sendButton").addEventListener("click", function (event) {
    var user = document.getElementById("userInput").value;
    var message = document.getElementById("messageInput").value;
    connection.invoke("SendMessage", user, message).catch(function (err) {
        return console.error(err.toString());
    });
    event.preventDefault();
});
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 40 12/21/2024