Skip to content

Commit d135f11

Browse files
authored
upgrade sample reference version (#128)
1 parent 83cd029 commit d135f11

File tree

6 files changed

+20
-51
lines changed

6 files changed

+20
-51
lines changed

samples/ChatRoom/ChatRoom.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.2</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
<UserSecretsId>chatroom</UserSecretsId>
55
<RootNamespace>Microsoft.Azure.SignalR.Samples.ChatRoom</RootNamespace>
66
</PropertyGroup>
@@ -10,7 +10,6 @@
1010
</ItemGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
14-
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.0.*" />
13+
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.*" />
1514
</ItemGroup>
1615
</Project>

samples/ChatRoom/Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

samples/ChatRoom/README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Then, let's update the chat room sample to use the new service you just created.
3838

3939
Let's look at the key changes:
4040

41-
1. In [Startup.cs](Startup.cs), instead of calling `AddSignalR()` and `UseSignalR()`, you need to call `AddAzureSignalR()` and `UseAzureSignalR()` and pass in connection string to make the application connect to the service instead of hosting SignalR by itself.
41+
1. In [Startup.cs](Startup.cs), call `AddAzureSignalR()` after `AddSignalR()` and pass in connection string to make the application connect to the service instead of hosting SignalR by itself.
4242

4343
```cs
4444
public void ConfigureServices(IServiceCollection services)
@@ -47,21 +47,12 @@ Let's look at the key changes:
4747
services.AddSignalR()
4848
.AddAzureSignalR();
4949
}
50-
51-
public void Configure(IApplicationBuilder app)
52-
{
53-
...
54-
app.UseAzureSignalR(routes =>
55-
{
56-
routes.MapHub<Chat>("/chat");
57-
});
58-
}
5950
```
6051

6152
You also need to reference the service SDK before using these APIs. This is how that would look in your ChatRoom.csproj file:
6253

6354
```xml
64-
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.0.*" />
55+
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.*" />
6556
```
6657

6758
Other than these changes, everything else remains the same, you can still use the hub interface you're already familiar with to write business logic.

samples/ChatRoom/Startup.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using Microsoft.AspNetCore.Builder;
5-
using Microsoft.Extensions.Configuration;
5+
using Microsoft.AspNetCore.Hosting;
66
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.Extensions.Hosting;
78

89
namespace Microsoft.Azure.SignalR.Samples.ChatRoom
910
{
1011
public class Startup
1112
{
12-
public Startup(IConfiguration configuration)
13-
{
14-
Configuration = configuration;
15-
}
16-
17-
public IConfiguration Configuration { get; }
18-
1913
public void ConfigureServices(IServiceCollection services)
2014
{
21-
services.AddMvc();
2215
services.AddSignalR()
2316
.AddAzureSignalR();
2417
}
2518

26-
public void Configure(IApplicationBuilder app)
19+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
2720
{
28-
app.UseMvc();
29-
app.UseFileServer();
30-
app.UseAzureSignalR(routes =>
21+
if (env.IsDevelopment())
22+
{
23+
app.UseDeveloperExceptionPage();
24+
}
25+
26+
app.UseDefaultFiles();
27+
app.UseStaticFiles();
28+
app.UseRouting();
29+
app.UseEndpoints(endpoints =>
3130
{
32-
routes.MapHub<ChatSampleHub>("/chat");
31+
endpoints.MapHub<ChatSampleHub>("/chat");
3332
});
3433
}
3534
}

samples/ChatRoom/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"IncludeScopes": false,
44
"Debug": {
55
"LogLevel": {
6-
"Default": "Debug"
6+
"Default": "Information"
77
}
88
},
99
"Console": {
1010
"LogLevel": {
11-
"Default": "Debug"
11+
"Default": "Information"
1212
}
1313
}
1414
}

samples/SimpleEcho/SimpleEcho.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.4.*" />
19+
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.*" />
2020
</ItemGroup>
2121

2222
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0' OR '$(TargetFramework)' == 'netcoreapp3.1'">

0 commit comments

Comments
 (0)