-
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
Showing
5 changed files
with
49 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Microsoft.AspNetCore.SignalR; | ||
|
||
namespace MadWorld.ShipSimulator.API.Hubs; | ||
|
||
public class CompanyHub : Hub | ||
{ | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
MadWorldVPS/MadWorld.ShipSimulator.API/Hubs/CompanyLiveUpdater.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,19 @@ | ||
using MadWorld.ShipSimulator.Domain.Companies; | ||
using Microsoft.AspNetCore.SignalR; | ||
|
||
namespace MadWorld.ShipSimulator.API.Hubs; | ||
|
||
public class CompanyLiveUpdater : ICompanyLiveUpdater | ||
{ | ||
private readonly IHubContext<CompanyHub> _hubContext; | ||
|
||
public CompanyLiveUpdater(IHubContext<CompanyHub> hubContext) | ||
{ | ||
_hubContext = hubContext; | ||
} | ||
|
||
public async Task UpdateCompanyAsync(Company company) | ||
{ | ||
await _hubContext.Clients.User(company.UserId.ToString()).SendAsync("CompanyUpdated", company); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
MadWorldVPS/MadWorld.ShipSimulator.API/Hubs/HubExtensions.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,12 @@ | ||
using MadWorld.ShipSimulator.Domain.Companies; | ||
|
||
namespace MadWorld.ShipSimulator.API.Hubs; | ||
|
||
public static class HubExtensions | ||
{ | ||
public static void AddHubs(this WebApplicationBuilder builder) | ||
{ | ||
builder.Services.AddSignalR(); | ||
builder.Services.AddScoped<ICompanyLiveUpdater, CompanyLiveUpdater>(); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
MadWorldVPS/MadWorld.ShipSimulator.Domain/Companies/ICompanyLiveUpdater.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,6 @@ | ||
namespace MadWorld.ShipSimulator.Domain.Companies; | ||
|
||
public interface ICompanyLiveUpdater | ||
{ | ||
Task UpdateCompanyAsync(Company company); | ||
} |