SignalR支持长轮训和WebSocket

parent 61bf169d
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net5.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<DebugType>embedded</DebugType>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<PublishSingleFile>True</PublishSingleFile>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishReadyToRun>True</PublishReadyToRun>
<SiteUrlToLaunchAfterPublish />
<PublishTrimmed>True</PublishTrimmed>
<ProjectGuid>3ae00ff5-f0ba-4d72-a23b-770186309327</ProjectGuid>
</PropertyGroup>
</Project>
\ No newline at end of file
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
using Performance.DtoModels; using Performance.DtoModels;
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using System;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
...@@ -87,7 +89,11 @@ public void ConfigureServices(IServiceCollection services) ...@@ -87,7 +89,11 @@ public void ConfigureServices(IServiceCollection services)
services.AddDependencyInjectionConfiguration(); services.AddDependencyInjectionConfiguration();
// signalr // signalr
services.AddSignalR(); services.AddSignalR(hubOptions =>
{
hubOptions.EnableDetailedErrors = true;
hubOptions.KeepAliveInterval = TimeSpan.FromMinutes(1);
});
// cors // cors
services.AddCors(options => services.AddCors(options =>
...@@ -132,7 +138,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) ...@@ -132,7 +138,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapHub<AllotLogHub>("/performance/allotLogHub"); endpoints.MapHub<AllotLogHub>("/performance/allotLogHub", options =>
{
options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling;
options.WebSockets.CloseTimeout = TimeSpan.FromMinutes(1);
});
endpoints.MapControllers(); endpoints.MapControllers();
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment