Skip to content

Commit

Permalink
Use aspnetcore.SignalR insted of blazor extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
meirkr committed May 17, 2020
1 parent 88f2730 commit 0f95bfd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion BlazorChat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blazor.Extensions.SignalR" Version="1.1.0-preview3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-rc1.20223.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-rc1.20223.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-rc1.20223.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.4" />
<PackageReference Include="System.Net.Http.Json" Version="3.2.0-rc1.20217.1" />
</ItemGroup>

Expand Down
21 changes: 12 additions & 9 deletions Components/Chat.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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



Expand Down
2 changes: 1 addition & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 0f95bfd

Please sign in to comment.