Skip to content

Commit

Permalink
fixes #9869 (#9870)
Browse files Browse the repository at this point in the history
* fixes #9869

* removed one line from code sample
  • Loading branch information
bradygaster authored and tdykstra committed Dec 6, 2018
1 parent 40f4fc0 commit 72f4937
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions aspnetcore/signalr/javascript-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Reference the SignalR JavaScript client in the `<script>` element.

The following code creates and starts a connection. The hub's name is case insensitive.

[!code-javascript[Call hub methods](javascript-client/sample/wwwroot/js/chat.js?range=9-12,28)]
[!code-javascript[Call hub methods](javascript-client/sample/wwwroot/js/chat.js?range=9-12)]

### Cross-origin connections

Expand Down Expand Up @@ -80,7 +80,7 @@ SignalR determines which client method to call by matching the method name and a

Chain a `catch` method to the end of the `start` method to handle client-side errors. Use `console.error` to output errors to the browser's console.

[!code-javascript[Error handling](javascript-client/sample/wwwroot/js/chat.js?range=28)]
[!code-javascript[Error handling](javascript-client/sample/wwwroot/js/chat.js?range=43-45)]

Setup client-side log tracing by passing a logger and type of event to log when the connection is made. Messages are logged with the specified log level and higher. Available log levels are as follows:

Expand All @@ -100,7 +100,7 @@ The JavaScript client for SignalR doesn't automatically reconnect. You must writ
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[Reconnect the JavaScript client](javascript-client/sample/wwwroot/js/chat.js?range=30-42)]
[!code-javascript[Reconnect the JavaScript client](javascript-client/sample/wwwroot/js/chat.js?range=28-40)]

A real-world implementation would use an exponential back-off or retry a specified number of times before giving up.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ connection.onclose(async () => {
await start();
});

/* this is here to show an alternative to start, including the catch
connection.start().catch(function (err) {
return console.error(err.toString());
});
*/

0 comments on commit 72f4937

Please sign in to comment.