I am building a user location tracking application for a client.
I am getting the location via Client (Android) using SignalR Hub Method and Saving in MongoDb
My Code
public async Task UpdateLocation(double latitude, double longitude)
{
await _mediator.Send(new UpdateLocationRequestModel()
{
Latitude = latitude,
Longitude = longitude,
UserId = Context.User.GetUserId()
});
}
Now I want another Client (Web) to view that updates of a specific user in real time.
How can I do that?
My Theoretical Solution
I was thinking of creating a method in the Hub as when the Client (Web) pushes a button a method will be called
public async Task ShowUser(string userId)
{
//Add To Redis Cache ('track',userId)
}
public async Task UpdateLocation(double latitude, double longitude)
{
await _mediator.Send(new UpdateLocationRequestModel()
{
Latitude = latitude,
Longitude = longitude,
UserId = Context.User.GetUserId()
});
// Check Redis Cahce for 'track'
// Send Data to Client(Web)
}
I haven't tested this but is there a better way?