在谷歌播放服务离开空房后如何停止握手过程?

时间:2013-08-02 17:08:22

标签: google-play-services multiplayer

离开后如何停止连接房间?这是一个场景(例如google的buttonclicker2000示例):

客户端1点击"快速游戏"然后单击后退按钮 - 返回菜单

客户端2点击"快速游戏"和(!)加入房间。查看客户端1,游戏开始。虽然客户1确实留有空间而不想玩。

在指示客户端1可以启动游戏的描述中,在这种情况下,可能继续运行握手过程。但对我来说,已经不再需要了。例如客户改变主意,可能想创建另一个房间。如何停止握手过程而不停止活动? (对不起我的英文)

log:
client 1

Sign-in succeeded.
onRoomCreated
Leaving room. (here i'am want kill the my room, but how?)
...
onConnectedToRoom  !!!
->nothing

client 2
Sign-in succeeded.
onRoomCreated
onConnectedToRoom.
->game started

1 个答案:

答案 0 :(得分:0)

如果您的播放器因网络问题而与游戏断开连接,您将在DisconnectedFromRoom上收到回调。

您的播放器可以(并且应该)调用GamesClient.leaveRoom通知其他玩家您已离开。

假设您已经实施了RoomStatusUpdate侦听器,那么您的玩家的对手将获得关于PeerLeft或onPeerDisconnected的回调。

更多信息位于https://developers.google.com/games/services/android/multiplayer#leaving_the_room

还有 https://developers.google.com/games/services/android/multiplayer#detecting_when_a_player_is_disconnected

相关问题