最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How can I detect when the client disconnects in dart gRPC api - Stack Overflow

programmeradmin1浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论