![]() |
VOOZH | about |
dotnet add package SrtsNetLayer --version 0.2.1
NuGet\Install-Package SrtsNetLayer -Version 0.2.1
<PackageReference Include="SrtsNetLayer" Version="0.2.1" />
<PackageVersion Include="SrtsNetLayer" Version="0.2.1" />Directory.Packages.props
<PackageReference Include="SrtsNetLayer" />Project file
paket add SrtsNetLayer --version 0.2.1
#r "nuget: SrtsNetLayer, 0.2.1"
#:package SrtsNetLayer@0.2.1
#addin nuget:?package=SrtsNetLayer&version=0.2.1Install as a Cake Addin
#tool nuget:?package=SrtsNetLayer&version=0.2.1Install as a Cake Tool
Based on SignalR Core
With the SrTs-NetLayer the connection is authenticated and the authentication result stored on the server through the connection object, like a session. It is not necessary to tell the client any resulting information or session ids. Since a connection has to be re-authenticated after an intermittent disconnect and the subsequent reconnect, it is convenient to have the client persist enough information to restore the session on a reconnect, like a session token or a JWT.
With SrTsNetLayer there are two main ways to authenticate a connection ...
use setAuth(bearerToken) or Component.props.BearerAuth with default SignalR auth
The connection will be authenticated while being established and no boundaries can be called without being authenticated. An can be implemented much to the same effect.
LoginBoundary, setConnectionParameters
Since connections are supposed to be long lived, NetLayerAuth is preferred
The AuthorizeAttribute is not yet available four BoundaryMethods
The Authorize Attribute required middlewares:
public void ConfigureServices(IServiceCollection services) {
services.AddCors();
services.AddSrTsNetLayer(options => { });
services.AddBoundariesFromAssemblyScan(GetType().Assembly);
// Alternativley add them manually
// services.AddSingleton<IBoundarySupplier, ProxyBoundarySupplier>();
// services.AddBoundary<SomeBoundary>();
// ...
var jsonOptions = new JsonSerializerOptions() {
WriteIndented = false,
DictionaryKeyPolicy = null,
IncludeFields = false,
NumberHandling = JsonNumberHandling.AllowReadingFromString,
AllowTrailingCommas = true,
ReadCommentHandling = JsonCommentHandling.Skip,
UnknownTypeHandling = JsonUnknownTypeHandling.JsonElement,
PropertyNameCaseInsensitive = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
// for MemberCasing.PascalCase during generation
PropertyNamingPolicy = null;
// for MemberCasing.JavascriptCamelCase during generation
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
jsonOptions.Converters.Add(new JsonStringEnumConverter());
jsonOptions.Converters.Add(new TimespanConverter());
services.AddSingleton(jsonOptions);
services.AddSignalR(options => { options.EnableDetailedErrors = false; }).AddJsonProtocol(options => {
options.PayloadSerializerOptions = jsonOptions;
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
app.UseWebSockets(new WebSocketOptions {
KeepAliveInterval = TimeSpan.FromSeconds(120),
// For development
AllowedOrigins = { "http://localhost:1234", $"http://{Environment.MachineName}:1234", "http://localhost:8080", $"http://{Environment.MachineName}:8080",
// For production
"http://localhost:80", $"http://{Environment.MachineName}:80", "https://localhost:443", $"https://{Environment.MachineName}:443" },
});
app.UseSrTsNetLayer()
.AddConnectionMiddleware<ConnectionTimerMiddleware>()
.AddBroadcastMiddleware<DefaultBroadcastMiddleware>()
.AddRequestMiddleware<RequestTimingMiddleware>()
#if DEBUG
.AddRequestMiddleware<DeveloperExceptionMiddleware>()
#endif
.AddRequestMiddleware<EndpointRoutingMiddleware>()
.AddRequestMiddleware<AuthorizationMiddleware>()
.AddRequestMiddleware<RequestEndpointMiddleware>()
;
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.