-
Notifications
You must be signed in to change notification settings - Fork 2
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
c60bd67
commit 0741340
Showing
14 changed files
with
134 additions
and
108 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
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
53 changes: 0 additions & 53 deletions
53
Source/Modules/TenantIdentity/Web/Server/SignalR/NotificationHub.cs
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
Source/Modules/TenantIdentity/Web/Server/SignalR/SignalRDIRegistrator.cs
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
Source/Modules/TenantIdentity/Web/Server/SignalR/SignalRRoutingRegistrator.cs
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Shared.Features.Messaging; | ||
using Shared.Features.EFCore; | ||
using Shared.Features.Modules; | ||
using Shared.Features.Server.ExecutionContext; | ||
|
||
namespace Shared.Features | ||
{ | ||
public static class Registrator | ||
{ | ||
public static IServiceCollection AddSharedFeatures(this IServiceCollection services) | ||
{ | ||
var serviceProvider = services.BuildServiceProvider(); | ||
var configuration = serviceProvider.GetRequiredService<IConfiguration>(); | ||
|
||
services.AddMessaging(); | ||
services.AddEFCore(configuration); | ||
services.AddServerExecutionContext(); | ||
|
||
return services; | ||
} | ||
|
||
public static IApplicationBuilder UseSharedFeaturesMiddleware(this IApplicationBuilder app, IWebHostEnvironment env) | ||
{ | ||
app.UseEFCoreMiddleware(); | ||
app.UseServerExecutionContextMiddleware(); | ||
app.UseModulesMiddleware(env); | ||
|
||
return app; | ||
} | ||
} | ||
} |
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,8 @@ | ||
using Microsoft.AspNetCore.SignalR; | ||
|
||
namespace Shared.Features.SignalR | ||
{ | ||
public class NotificationHub : Hub | ||
{ | ||
} | ||
} |
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,26 @@ | ||
using Microsoft.AspNetCore.SignalR; | ||
using Shared.Kernel.Constants; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Shared.Features.SignalR | ||
{ | ||
public class NotificationHubService | ||
{ | ||
private readonly IHubContext<NotificationHub> notificationHubContext; | ||
|
||
public NotificationHubService(IHubContext<NotificationHub> notificationHubContext) | ||
{ | ||
this.notificationHubContext = notificationHubContext; | ||
} | ||
|
||
public async Task SendNotificationAsync(Guid userId, string triggeredMethodName) | ||
{ | ||
await notificationHubContext.Clients.User(userId.ToString()).SendAsync(triggeredMethodName); | ||
} | ||
} | ||
} |
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,27 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.SignalR; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Shared.Kernel.Constants; | ||
|
||
namespace Shared.Features.SignalR | ||
{ | ||
public static class Registrator | ||
{ | ||
public static IServiceCollection Add_SignalR(this IServiceCollection services) | ||
{ | ||
services.AddSingleton<IUserIdProvider, UserIdProvider>(); | ||
services.AddScoped<NotificationHubService>(); | ||
return services; | ||
} | ||
|
||
public static IApplicationBuilder UseSignalRMiddleware(this IApplicationBuilder app) | ||
{ | ||
app.UseEndpoints(endpoints => | ||
{ | ||
endpoints.MapHub<NotificationHub>(NotificationHubConstants.Hub); | ||
}); | ||
|
||
return app; | ||
} | ||
} | ||
} |
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.SignalR; | ||
using Shared.Kernel.Extensions.ClaimsPrincipal; | ||
|
||
namespace Shared.Features.SignalR | ||
{ | ||
public class UserIdProvider : IUserIdProvider | ||
{ | ||
public string GetUserId(HubConnectionContext connection) | ||
{ | ||
return connection.User.Identity.IsAuthenticated | ||
? connection.User?.GetUserId<string>() | ||
: string.Empty; | ||
} | ||
} | ||
} |
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,7 @@ | ||
namespace Shared.Kernel.Constants | ||
{ | ||
public class NotificationHubConstants | ||
{ | ||
public const string Hub = "NotificationHub"; | ||
} | ||
} |
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
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
This file was deleted.
Oops, something went wrong.