I have a Singleton service, GameServer
which keeps track of guests to a particular page, a Game.razor
page, and a Scoped service, GameBridge
, between them. Gamebridge
is injected into Game.razor
, and GameServer
is injected into Gamebridge
.
GameServer
sends out a ping event, which is relayed by GameBridge
to the page. The page then calls a method in Gamebridge
, which is relayed to GameServer
, and sets a LastSeen
DateTime to DateTime.Now for the user.
The idea was that if the user closes their browser, the Scoped service would be disposed, and the GameServer
would no longer get update pings from the user, i.e. the user has timed out, and games can be forfeited, game rooms abandoned and so on.
The problem is that even if the browser is closed, Game.razor
and GameBridge
keep chugging along like everything's fine-- which I can see because the time value for the missing user keeps updating. As of right now, I cannot detect the user disconnection even when they close the browser in blazor server side.