Skip to content

Commit bcd047c

Browse files
committed
Initial commit
0 parents  commit bcd047c

38 files changed

+26040
-0
lines changed

Diff for: .gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bin/
2+
obj/
3+
.vs/
4+
*.suo
5+
node_modules/
6+
publish/

Diff for: RoundTheCode.ReactSignalR.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30204.135
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RoundTheCode.ReactSignalR", "RoundTheCode.ReactSignalR\RoundTheCode.ReactSignalR.csproj", "{FA542230-C9B2-4B04-B401-BFBFF0D0E4F0}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{FA542230-C9B2-4B04-B401-BFBFF0D0E4F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{FA542230-C9B2-4B04-B401-BFBFF0D0E4F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{FA542230-C9B2-4B04-B401-BFBFF0D0E4F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{FA542230-C9B2-4B04-B401-BFBFF0D0E4F0}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {3E4BAF72-359D-4FFF-9C92-3180D80A71E2}
24+
EndGlobalSection
25+
EndGlobal

Diff for: RoundTheCode.ReactSignalR/.config/dotnet-tools.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-ef": {
6+
"version": "3.1.7",
7+
"commands": [
8+
"dotnet-ef"
9+
]
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Mvc;
7+
using Microsoft.AspNetCore.SignalR;
8+
using RoundTheCode.ReactSignalR.Hubs;
9+
10+
namespace RoundTheCode.ReactSignalR.Controllers
11+
{
12+
[ApiController]
13+
[Route("api/message")]
14+
public class MessageController : Controller
15+
{
16+
protected readonly IHubContext<MessageHub> _messageHub;
17+
18+
public MessageController([NotNull] IHubContext<MessageHub> messageHub)
19+
{
20+
_messageHub = messageHub;
21+
}
22+
23+
[HttpPost]
24+
public async Task<IActionResult> Create(MessagePost messagePost)
25+
{
26+
await _messageHub.Clients.All.SendAsync("sendToReact", "The message '" + messagePost.Message + "' has been received");
27+
28+
return Ok();
29+
}
30+
}
31+
32+
public class MessagePost
33+
{
34+
public virtual string Message { get; set; }
35+
}
36+
}

Diff for: RoundTheCode.ReactSignalR/Hubs/MessageHub.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.AspNetCore.SignalR;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace RoundTheCode.ReactSignalR.Hubs
8+
{
9+
public class MessageHub : Hub
10+
{
11+
}
12+
}

Diff for: RoundTheCode.ReactSignalR/Program.cs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace RoundTheCode.ReactSignalR
11+
{
12+
public class Program
13+
{
14+
public static void Main(string[] args)
15+
{
16+
CreateHostBuilder(args).Build().Run();
17+
}
18+
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
<PropertyGroup>
7+
<DeleteExistingFiles>False</DeleteExistingFiles>
8+
<ExcludeApp_Data>False</ExcludeApp_Data>
9+
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
10+
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
11+
<LastUsedPlatform>Any CPU</LastUsedPlatform>
12+
<PublishProvider>FileSystem</PublishProvider>
13+
<PublishUrl>C:\Users\graced\RoundTheCode.ReactSignalR\Website</PublishUrl>
14+
<WebPublishMethod>FileSystem</WebPublishMethod>
15+
<SiteUrlToLaunchAfterPublish />
16+
<TargetFramework>netcoreapp3.1</TargetFramework>
17+
<ProjectGuid>fa542230-c9b2-4b04-b401-bfbff0d0e4f0</ProjectGuid>
18+
<SelfContained>false</SelfContained>
19+
</PropertyGroup>
20+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
<PropertyGroup>
7+
<_PublishTargetUrl>C:\Users\graced\RoundTheCode.ReactSignalR\Website</_PublishTargetUrl>
8+
</PropertyGroup>
9+
</Project>
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:58205",
8+
"sslPort": 44351
9+
}
10+
},
11+
"profiles": {
12+
"IIS Express": {
13+
"commandName": "IISExpress",
14+
"launchBrowser": true,
15+
"launchUrl": "clientapp",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"RoundTheCode.ReactSignalR": {
21+
"commandName": "Project",
22+
"launchBrowser": true,
23+
"launchUrl": "weatherforecast",
24+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
25+
"environmentVariables": {
26+
"ASPNETCORE_ENVIRONMENT": "Development"
27+
}
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
6+
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
7+
<IsPackable>false</IsPackable>
8+
<SpaRoot>clientapp\</SpaRoot>
9+
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
10+
<UserSecretsId>d2c17eee-1b0f-4bce-903d-b14d6dac95cc</UserSecretsId>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="5.0.2" />
15+
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="3.1.11" />
16+
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.2" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<!-- Don't publish the SPA source files, but do show them in the project files list -->
21+
<Content Remove="$(SpaRoot)**" />
22+
<None Remove="$(SpaRoot)**" />
23+
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
24+
</ItemGroup>
25+
26+
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition="'$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
27+
28+
<!-- Ensure Node.js is installed -->
29+
<Exec Command="node --version" ContinueOnError="true">
30+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
31+
</Exec>
32+
33+
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
34+
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
35+
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
36+
</Target>
37+
38+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
39+
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
40+
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
41+
<Exec WorkingDirectory="$(SpaRoot)" Command="yarn build:iis" />
42+
43+
<!-- Include the newly-built files in the publish output -->
44+
<ItemGroup>
45+
<DistFiles Include="$(SpaRoot)build\**" />
46+
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
47+
<RelativePath>%(DistFiles.Identity)</RelativePath>
48+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
49+
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
50+
</ResolvedFileToPublish>
51+
</ItemGroup>
52+
</Target>
53+
54+
55+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
5+
<Controller_SelectedScaffolderCategoryPath>root/Controller</Controller_SelectedScaffolderCategoryPath>
6+
<NameOfLastUsedPublishProfile>FolderProfile</NameOfLastUsedPublishProfile>
7+
</PropertyGroup>
8+
</Project>

Diff for: RoundTheCode.ReactSignalR/Startup.cs

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.AspNetCore.HttpsPolicy;
8+
using Microsoft.AspNetCore.Mvc;
9+
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
10+
using Microsoft.Extensions.Configuration;
11+
using Microsoft.Extensions.DependencyInjection;
12+
using Microsoft.Extensions.Hosting;
13+
using Microsoft.Extensions.Logging;
14+
using RoundTheCode.ReactSignalR.Hubs;
15+
16+
namespace RoundTheCode.ReactSignalR
17+
{
18+
public class Startup
19+
{
20+
public Startup(IConfiguration configuration)
21+
{
22+
Configuration = configuration;
23+
}
24+
25+
public IConfiguration Configuration { get; }
26+
27+
// This method gets called by the runtime. Use this method to add services to the container.
28+
public void ConfigureServices(IServiceCollection services)
29+
{
30+
services.AddControllers();
31+
32+
services.AddSpaStaticFiles(configure =>
33+
{
34+
configure.RootPath = "clientapp/build";
35+
});
36+
37+
services.AddSignalR();
38+
}
39+
40+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
41+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
42+
{
43+
if (env.IsDevelopment())
44+
{
45+
app.UseDeveloperExceptionPage();
46+
}
47+
48+
app.UseHttpsRedirection();
49+
50+
app.UseSpaStaticFiles(new StaticFileOptions { RequestPath = "/clientapp/build" } );
51+
52+
app.UseRouting();
53+
54+
app.UseAuthorization();
55+
56+
app.UseEndpoints(endpoints =>
57+
{
58+
endpoints.MapHub<MessageHub>("/message");
59+
60+
endpoints.MapControllers();
61+
});
62+
63+
app.UseSpa(spa =>
64+
{
65+
spa.Options.SourcePath = "clientapp";
66+
67+
if (env.IsDevelopment())
68+
{
69+
spa.UseReactDevelopmentServer(npmScript: "start");
70+
}
71+
});
72+
73+
74+
}
75+
}
76+
}

Diff for: RoundTheCode.ReactSignalR/WeatherForecast.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace RoundTheCode.ReactSignalR
4+
{
5+
public class WeatherForecast
6+
{
7+
public DateTime Date { get; set; }
8+
9+
public int TemperatureC { get; set; }
10+
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12+
13+
public string Summary { get; set; }
14+
}
15+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
}
9+
}

Diff for: RoundTheCode.ReactSignalR/appsettings.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
},
9+
"AllowedHosts": "*"
10+
}

Diff for: RoundTheCode.ReactSignalR/clientapp/.env.iis

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PUBLIC_URL=/clientapp/build

Diff for: RoundTheCode.ReactSignalR/clientapp/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

0 commit comments

Comments
 (0)