real time updates on Ready page from different users
Closed this issue · 1 comments
On the Ready page, we should see updates (adds and removals) of other players without needing to refresh the page.
I have a StateContainer that relays appropriate events, and they even show up in the debugger in the right handler, but the page won't refresh. That is, this StateHasChanged call is having no effect. I tried await InvokeAsync(StateHasChanged)
and this didn't work.
Here's a little demo of how I'm approaching this:
https://1drv.ms/v/s!AvguHRnyJtWMm_wNRA5DTPv9LSSYew?e=ZbzAvS
this is mostly working now via
- some event messaging methods at the DbContext level. This is populating a queue table EventMessage.
- a background service that monitors the queue table (using Dapper!)
- a "middle man" EventRelay that connects the background service to the UI with the actual event members. I tried having the events directly on the background service, but this didn't work. I couldn't add event subscriptions directly to a hosted service.
Brief demo
https://1drv.ms/v/s!AvguHRnyJtWMm_wPzHQJQLGgbpwMqw?e=AhNoij
I was trying to avoid using SignalR directly because I've never really understood it. But this is a little complicated what I've done here, so I don't know. Solution above doesn't handle the case when a single ready player is left -- something like that. I do like the durability of a SQL Server queue table and internal messaging infrastructure since it's purpose-built for game data in this app.