mirror of
https://github.com/fiodarsazanavets/aspire-13-examples.git
synced 2026-06-20 12:23:14 +00:00
Add initial implementation of RbbitMQ
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace OnlineShop.ApiService;
|
||||
|
||||
public class LocationUpdater(
|
||||
IHubContext<LocationHub> locationHub) :
|
||||
BackgroundService
|
||||
{
|
||||
protected async override Task
|
||||
ExecuteAsync(
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
await Task.Delay(5000, cancellationToken);
|
||||
await UpdateLocation(
|
||||
51.5074, -0.1276, cancellationToken);
|
||||
|
||||
await Task.Delay(5000, cancellationToken);
|
||||
await UpdateLocation(
|
||||
51.5074, -0.13, cancellationToken);
|
||||
|
||||
await Task.Delay(5000, cancellationToken);
|
||||
await UpdateLocation(
|
||||
51.508, -0.14, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task UpdateLocation(
|
||||
double latitude,
|
||||
double longitude,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
await locationHub.Clients.All.SendAsync(
|
||||
"ReceiveLocationUpdate",
|
||||
latitude,
|
||||
longitude,
|
||||
cancellationToken);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user