When a peer disconected from a room in google play services

旧时模样 提交于 2020-02-28 18:56:52

问题


What is the different between a peer dissconnected to a peer leaving a room.

if a participent disconnect from a room, what would his status be? STATUS_JOINED or STATUS_LEFT?

I'm working on a fairly long turn based game (should be a few minutes game) and i believe there would be alot of disconnecting cases that i would like to resolve.

Would it be possible to resend an invitation to the disconnected user and get him back to the room?

if the room creator got disconnected, and the previuse was possible, would he still be the creator of that game after reconnecting?


回答1:


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!



来源:https://stackoverflow.com/questions/19202066/when-a-peer-disconected-from-a-room-in-google-play-services

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