-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18c1695
commit 8163b4f
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...tructure/BuildingBlock.Infrastructure.SignalR/BuildingBlock.Infrastructure.SignalR.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PackageId>Phuc1403.BuildingBlock.Infrastructure.SignalR</PackageId> | ||
<Version>$([System.DateTime]::Now.ToString("yyyy.MM.dd.HHmm"))</Version> | ||
<Authors>Phuc Pham Hong</Authors> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App"/> | ||
</ItemGroup> | ||
</Project> |
11 changes: 11 additions & 0 deletions
11
Infrastructure/BuildingBlock.Infrastructure.SignalR/Hub.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.AspNetCore.SignalR; | ||
|
||
namespace BuildingBlock.Infrastructure.SignalR; | ||
|
||
public class Hub : Microsoft.AspNetCore.SignalR.Hub | ||
{ | ||
public override async Task OnConnectedAsync() | ||
{ | ||
await Clients.All.SendAsync("ReceiveMessage", $"{Context.ConnectionId} joined the chat"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Presentation/BuildingBlock.Presentation.API/Extensions/RealTimeExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace BuildingBlock.Presentation.API.Extensions; | ||
|
||
public static class RealTimeExtension | ||
{ | ||
public static IServiceCollection AddRealTime(this IServiceCollection services) | ||
{ | ||
services.AddSignalR(); | ||
|
||
return services; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Presentation/BuildingBlock.Presentation.API/Middlewares/RealTimeMiddleware.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Routing; | ||
using Microsoft.AspNetCore.SignalR; | ||
|
||
namespace BuildingBlock.Presentation.API.Middlewares; | ||
|
||
public static class RealTimeMiddleware | ||
{ | ||
public static IEndpointRouteBuilder UseRealTime(this IEndpointRouteBuilder app) | ||
{ | ||
app.MapHub<Hub>("hub"); | ||
|
||
return app; | ||
} | ||
} |