SignalR with TypeScript code examples do not match other articles
The method used in the TypeScript example for ChatHub.cs is:
public async Task NewMessage(long username, string message)
{
await Clients.All.SendAsync("messageReceived", username, message);
}
Both the JavaScript and Blazor examples use:
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
The differences being:
NewMessage->SendMessagelong username->string user"messageReceived"->"ReceiveMessage"
This is also present in the .ts/.js.|.razor examples where they call the methods, and anywhere in the article that references to it of course.
Biggest difference (besides the name changes) is that the TypeScript example doesn't have a username input field, it just uses the Date().getTime() value
A smaller but similiar difference is the endpoint defined:
TypeScript example
endpoints.MapHub<ChatHub>("/hub");
versus the JavaScript and Blazor example:
endpoints.MapHub<ChatHub>("/chathub");
This tripped me up personally when I was reading the Strongly Typed Hubs article that uses the JavaScript and Blazor example syntax
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 47557f89-3a14-1139-0074-38d931b35faf
- Version Independent ID: 1cee43b4-b672-e480-3e26-72e08a6c2d77
- Content: Use ASP.NET Core SignalR with TypeScript and Webpack
- Content Source: aspnetcore/tutorials/signalr-typescript-webpack.md
- Product: aspnet-core
- Technology: aspnetcore-tutorials
- GitHub Login: @ssougnez
- Microsoft Alias: bradyg