cutoff snippets fixed (#22826)

pull/22835/head
Fiyaz Bin Hasan 2021-07-23 19:52:47 +06:00 committed by GitHub
parent 1eeb2c5b3a
commit 0986702177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -60,7 +60,7 @@ The client library is available on the following CDNs:
The following code creates and starts a connection. The hub's name is case insensitive:
[!code-javascript[](javascript-client/samples/3.x/SignalRChat/wwwroot/chat.js?range=3-6,29-43)]
[!code-javascript[](javascript-client/samples/3.x/SignalRChat/wwwroot/chat.js?range=3-6,29-45)]
### Cross-origin connections
@ -261,7 +261,7 @@ The following code demonstrates a typical manual reconnection approach:
1. A function (in this case, the `start` function) is created to start the connection.
1. Call the `start` function in the connection's `onclose` event handler.
[!code-javascript[](javascript-client/samples/3.x/SignalRChat/wwwroot/chat.js?range=30-40)]
[!code-javascript[](javascript-client/samples/3.x/SignalRChat/wwwroot/chat.js?range=30-42)]
A real-world implementation would use an exponential back-off or retry a specified number of times before giving up.

View File

@ -37,12 +37,8 @@ document.addEventListener("DOMContentLoaded", () => {
}
};
connection.onclose(function (error) {
if (error) {
console.log(`Connection closed with error: ${error}`);
} else {
console.log("Connection closed.");
}
connection.onclose(async () => {
await start();
});
// Start the connection.