When a peer disconected from a room in google play services

♀尐吖头ヾ 提交于 2019-12-06 10:09:06

The first caveat is that the Real Time Multiplayer API is not really meant for turn-based games. So if someone gets dropped from the room, they can't get re-added; also, you can't remain in the room if your Activity goes to the background. Now, to get to the question:

  1. If a participant leaves the room, their status is STATUS_LEFT. If they are in the room but can't be reached yet (i.e. the player is not yet part of the P2P connected graph), they might be in the STATUS_JOINED state, but not connected. Also, due to a bug, you might see a participant who has STATUS_LEFT but still reports as connected. So, in your logic to check if a participant is "really there", you should check that they are in STATUS_JOINED state and connected (not just one or the other).

  2. You can't re-send an invite to a disconnected user to get them back in the room. But if all players have the game state, nothing prevents you from building a new room from scratch to continue the game. Of course, this won't work with automatch (because you can't request a new room with the same participants as the old one), but would work when players are playing with friends from their circles.

  3. There is no such thing as the "room owner" -- it's a P2P symmetrical network. If player A creates the room and invites player B and player C, player A can then leave the room and the room will still work for players B and C. There is no requirement that the creator of the room remain in the room.

Hope this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!