gpt4 book ai didi

android - 检测其他玩家是否无意中离开(例如互联网断开连接)并重新连接 - Google play real time multiplayer

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:14:55 25 4
gpt4 key购买 nike

我正在实现 google play 游戏服务实时多人游戏。

目前,如果我在一个客户端上关闭 WIFI,另一个客户端不会检测到连接丢失。没有调用 PeerDisconnect 事件。

1 - API 是否提供任何东西来检查对等点是否仍然连接?

2 - 有没有办法让玩家重新连接到房间?

最佳答案

1 - API 是否提供任何东西来检查对等点是否仍然连接?

Connecting players 中所述,您可以使用 RoomStatusUpdateListener 回调监控参与者的连接状态。如前所述:

To be notified when all players are connected, your game can use the RoomUpdateListener.onRoomConnected() callback. Your game can also use the RoomStatusUpdateListener callbacks to monitor the connection status of the participants. Based on the participant connection status, your game can decide whether to start or cancel the gaming session.

2 - 有没有办法让玩家重新连接到房间?

实时多人游戏 - Gameplay指出:

Once the required number of participants for a room have been connected, the room is considered to be 'filled' and gameplay can begin. After participants join a room, your game can allow them to leave the room (effectively dropping them out of the game). However, no new players can join a room after it is 'filled' (not even to fill a spot that a participant has vacated).

除此之外,引用best practice for Real-time multiplayer :

If you don't leave the room appropriately, Google Play games services will continue to send event and invitation notifications to the client. You should leave the active room whenever one of these scenarios occurs:

  • Gameplay is over (for example, a player has won the match).
  • When your game goes into the background.
  • On Android, leave the room when:
    • The player cancels the game in the waiting room UI.
    • The response code returned in the onActivityResult() callback is GamesActivityResultCodes.RESULT_LEFT_ROOM.
    • The Activity onStop() is called. This might indicate that your Activity is being destroyed. In this case, leave the room and call disconnect().

希望这些链接能解决您的所有疑虑。编码愉快! :)

关于android - 检测其他玩家是否无意中离开(例如互联网断开连接)并重新连接 - Google play real time multiplayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37253737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com