From 0f95bfd373995c81635266ed78a8cd539c61b40d Mon Sep 17 00:00:00 2001 From: Meir Kriheli Date: Sun, 17 May 2020 10:41:36 +0300 Subject: [PATCH] Use aspnetcore.SignalR insted of blazor extensions --- BlazorChat.csproj | 2 +- Components/Chat.cs | 21 ++++++++++++--------- Program.cs | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/BlazorChat.csproj b/BlazorChat.csproj index 7de3cc1..d2d8059 100644 --- a/BlazorChat.csproj +++ b/BlazorChat.csproj @@ -7,10 +7,10 @@ - + diff --git a/Components/Chat.cs b/Components/Chat.cs index 75ce77f..99fc23f 100644 --- a/Components/Chat.cs +++ b/Components/Chat.cs @@ -1,10 +1,12 @@ using blazorChat.Models; -using Blazor.Extensions; using System; using System.Linq; using System.Collections.Generic; using Microsoft.AspNetCore.Components; using System.Threading.Tasks; +using Microsoft.AspNetCore.SignalR.Client; +using Microsoft.AspNetCore.Http.Connections; +using Microsoft.Extensions.Logging; namespace BlazorChat.Components { @@ -28,14 +30,15 @@ protected override async Task OnInitializedAsync() { var baseUri = NavigationManager.BaseUri; hub = _hubConnectionBuilder // the injected one from above. - //.WithUrl("http://localhost:5000/chat", - .WithUrl("/chat", // baseUri includes already '/' - opt => - { - opt.LogLevel = SignalRLogLevel.Trace; // Client log level - opt.Transport = HttpTransportType.WebSockets; // Which transport you want to use for this connection - }) - .Build(); // Build the HubConnection + .WithAutomaticReconnect() + //.WithUrl("http://localhost:5000/chat", + .WithUrl("/chat", + opt => + { + opt.Transports = HttpTransportType.WebSockets; // Which transport you want to use for this connection + }) + .ConfigureLogging(e => e.SetMinimumLevel(LogLevel.Warning)) + .Build(); // Build the HubConnection diff --git a/Program.cs b/Program.cs index 446adcf..b9531b6 100644 --- a/Program.cs +++ b/Program.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Blazor.Extensions; +using Microsoft.AspNetCore.SignalR.Client; namespace BlazorChat {