I am making a online game. The player is searching for a match so I am creating a "pool of players that are seeking for a match as well". If the user is tired of waiting and closes the site, I want to be able to trigger a action that will remove him from the pool. How can I detect that he unconnected from a match?
@override
Future<SearchMatchResponse> searchMatch(
ServiceCall call,
SearchMatchRequest request,
) async {
// Logic to search match
await Future.delayed(const Duration(seconds: 3));
// If client disconnects, I want to interrupt this process and remove him from the "players currently searching for a match" list
return SearchMatchResponse(
matchId: '123',
);
}
I am expecting an way to build a "onClientUnconnect" callback function