1- using System ;
21using System . Threading ;
32using System . Threading . Tasks ;
43using MediatR ;
54using Microsoft . AspNetCore . SignalR ;
65using NetCoreKit . Domain ;
7- using NetCoreKit . Samples . Contracts . Events ;
86
97namespace NetCoreKit . Samples . SignalRNotifier . Services . Hubs
108{
@@ -13,34 +11,32 @@ public class ProjectHub : Hub
1311 }
1412
1513 public class ProjectHostService : HostedService ,
16- INotificationHandler < ProjectCreated > ,
17- INotificationHandler < TaskCreated >
14+ INotificationHandler < Notifications . ProjectCreated > ,
15+ INotificationHandler < Notifications . TaskCreated >
1816 {
1917 private readonly IEventBus _eventBus ;
20- private readonly IServiceProvider _resolver ;
2118
22- public ProjectHostService ( IHubContext < ProjectHub > context , IServiceProvider resolver , IEventBus eventBus )
19+ public ProjectHostService ( IHubContext < ProjectHub > context , IEventBus eventBus )
2320 {
24- _resolver = resolver ;
2521 _eventBus = eventBus ;
2622 Clients = context . Clients ;
2723 }
2824
2925 private IHubClients Clients { get ; }
3026
31- public async Task Handle ( ProjectCreated @event , CancellationToken cancellationToken )
27+ public async Task Handle ( Notifications . ProjectCreated notification , CancellationToken cancellationToken )
3228 {
33- await Clients . All . SendAsync ( "projectCreatedNotify" , @event , cancellationToken ) ;
29+ await Clients . All . SendAsync ( "projectCreatedNotify" , notification , cancellationToken ) ;
3430 }
3531
36- public async Task Handle ( TaskCreated @event , CancellationToken cancellationToken )
32+ public async Task Handle ( Notifications . TaskCreated notification , CancellationToken cancellationToken )
3733 {
38- await Clients . All . SendAsync ( "taskAddedToProjectNotify" , @event , cancellationToken ) ;
34+ await Clients . All . SendAsync ( "taskAddedToProjectNotify" , notification , cancellationToken ) ;
3935 }
4036
4137 protected override Task ExecuteAsync ( CancellationToken cancellationToken )
4238 {
43- _eventBus . Subscribe ( "project" ) ;
39+ _eventBus . Subscribe ( "project" ) . Wait ( cancellationToken ) ;
4440 return Task . CompletedTask ;
4541 }
4642 }
0 commit comments