You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/ChatRoomLocal/README.md
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Let's implement this feature step by step.
24
24
dotnet new web
25
25
```
26
26
27
-
> Before you start, make sure you installed the latest [.NET Core 2.1 SDK](https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300).
27
+
> Before you start, make sure you installed the latest [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1).
28
28
29
29
2. Create a `Chat.cs` that defines a `Chat` hub class.
30
30
@@ -45,7 +45,7 @@ Let's implement this feature step by step.
45
45
}
46
46
```
47
47
48
-
> SignalR SDK is already *included* in `Microsoft.AspNetCore.App` package reference in ChatRoomLocal.csproj file.
48
+
> SignalR feature is already *available* as part of the `Microsoft.AspNetCore.App` shared framework.
49
49
50
50
Hub is the core concept in SignalR which exposes a set of methods that can be called from clients. Here we define two methods: `Broadcast()` which broadcasts the message to all clients and `Echo()` which sends the message back to the caller.
51
51
@@ -59,30 +59,35 @@ Let's implement this feature step by step.
59
59
services.AddSignalR();
60
60
}
61
61
62
-
public void Configure(IApplicationBuilder app)
62
+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
63
63
{
64
64
...
65
-
app.UseSignalR(routes =>
65
+
app.UseRouting();
66
+
app.UseEndpoints(endpoints =>
66
67
{
67
-
routes.MapHub<Chat>("/chat");
68
+
endpoints.MapHub<Chat>("/chat");
68
69
});
70
+
...
69
71
}
70
72
```
71
73
72
-
> Make sure you remove `app.Run(...)` from `Configure()`, which will always give you a Hello World page.
74
+
> Make sure you remove `endpoints.MapGet("/", async context =>...` from inside `app.UseEndpoint` in method `Configure()`, which will always give you a Hello World page.
73
75
74
76
The key changes here are `AddSignalR()` which initializes the SignalR runtime and `MapHub()` which maps the hub to the `/chat` endpoint so clients can access the hub using this url.
75
77
76
78
4. The last step is to create the UI of the chat room. In this sample, we will use HTML and Javascript to build a web application:
77
79
78
80
Copy the HTML and script files from [wwwroot](wwwroot/) of the sample project to the `wwwroot` folder of your project.
79
-
Add the following code to `Startup.cs` to make the application serve the pages:
81
+
Add the following code to `Startup.cs` above `app.UseRouting()` to make the application serve the pages:
80
82
81
83
```cs
82
84
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
0 commit comments