From 44e25e9f7ce427b9cf39a422535e34ba66bf0a06 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Wed, 5 Jun 2019 18:48:08 -0500 Subject: [PATCH] Drop Blazor Hosting Models section (#12717) * Drop Blazor Hosting Models section * Remove Disconnect and reconnect handling * Update date --- aspnetcore/blazor/hosting-models.md | 68 +---------------------------- 1 file changed, 1 insertion(+), 67 deletions(-) diff --git a/aspnetcore/blazor/hosting-models.md b/aspnetcore/blazor/hosting-models.md index 6ae46a08f1..323f29bae7 100644 --- a/aspnetcore/blazor/hosting-models.md +++ b/aspnetcore/blazor/hosting-models.md @@ -5,7 +5,7 @@ description: Understand client-side and server-side Blazor hosting models. monikerRange: '>= aspnetcore-3.0' ms.author: riande ms.custom: mvc -ms.date: 05/28/2019 +ms.date: 06/05/2019 uid: blazor/hosting-models --- # Blazor hosting models @@ -148,72 +148,6 @@ To configure the SignalR client in the *Pages/\_Host.cshtml* file: ``` -### Improved SignalR connection lifetime handling - -Automatic reconnects can be enabled by calling the `withAutomaticReconnect` method on `HubConnectionBuilder`: - -```csharp -const connection = new signalR.HubConnectionBuilder() - .withUrl("/chatHub") - .withAutomaticReconnect() - .build(); -``` - -Without specifying parameters, `withAutomaticReconnect` configures the client to try to reconnect, waiting 0, 2, 10, and 30 seconds between each attempt. - -To configure a non-default number of reconnect attempts before failure or to change the reconnect timing, `withAutomaticReconnect` accepts an array of numbers representing the delay in milliseconds to wait before starting each reconnect attempt: - -```csharp -const connection = new signalR.HubConnectionBuilder() - .withUrl("/chatHub") - .withAutomaticReconnect([0, 0, 2000, 5000]) // defaults to [0, 2000, 10000, 30000] - .build(); -``` - -### Improved disconnect and reconnect handling - -Before starting any reconnect attempts, the `HubConnection` transitions to the `Reconnecting` state and fires its `onreconnecting` callback. This provides an opportunity to warn users that the connection was lost, disable UI elements, and mitigate confusing user scenarios that might occur due to the disconnected state: - -```javascript -connection.onreconnecting((error) => { - console.assert(connection.state === signalR.HubConnectionState.Reconnecting); - - document.getElementById("messageInput").disabled = true; - - const li = document.createElement("li"); - li.textContent = `Connection lost due to error "${error}". Reconnecting.`; - document.getElementById("messagesList").appendChild(li); -}); -``` - -If the client successfully reconnects within its first four attempts, the `HubConnection` transitions back to the `Connected` state and fires `onreconnected` callback. This provides an opportunity to inform users that the connection is re-established: - -```javascript -connection.onreconnected((connectionId) => { - console.assert(connection.state === signalR.HubConnectionState.Connected); - - document.getElementById("messageInput").disabled = false; - - const li = document.createElement("li"); - li.textContent = `Connection reestablished. Connected with connectionId "${connectionId}".`; - document.getElementById("messagesList").appendChild(li); -}); -``` - -If the client doesn't successfully reconnect within its first four attempts, the `HubConnection` transitions to the `Disconnected` state and fires its `onclosed` callback. This is an opportunity to inform users that the connection is permanently lost and to recommend refreshing the page. - -```javascript -connection.onclose((error) => { - console.assert(connection.state === signalR.HubConnectionState.Disconnected); - - document.getElementById("messageInput").disabled = true; - - const li = document.createElement("li"); - li.textContent = `Connection closed due to error "${error}". Try refreshing this page to restart the connection.`; - document.getElementById("messagesList").appendChild(li); -}) -``` - ## Additional resources *