Google-Play-Services:创建自定义候车室用户界面 [英] Google-Play-Services: Creating custom waiting room UI

查看:162
本文介绍了Google-Play-Services:创建自定义候车室用户界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正要为我的android应用程序实现一个实时多人游戏,并使用谷歌玩游戏
服务,并且有一些问题需要听取更新。 Iam没那么有经验,
,所以请谅解可能的理解问题。

我的意图是我需要得到消息,如果有人加入了我最近的
创建了房间,或者自己创建了另一个房间,使用与我的房间相同的变体。



我试图在RoomStatusUpdateListener上听,但是在创建房间后,
这个监听器永远不会被调用,我不知道为什么。什么被调用,是
RoomUpdateListener,但它不包含我需要的回调方法。



我知道建议使用android build在
等候室ui中,并使用Games.RealTimeMultiplayer.getWaitingRoomIntent()来
启动一个activityForResult,但我需要创建类似我自己的等候室
的东西,但不知道如何。显然,谷歌活动(等待)的房间确实获得了
的变化通知,因此必须有一种方法来观察这些变化。



据我所知,Iam试图做以下事情:


  1. 创建具有不同变体的多个房间

  2. 更新空间(玩家加入或创建同一房间)
  3. 通过步骤2中的更新加入房间。

有人知道我该如何做到这一点吗?
我会很高兴。抱歉,我的英语不好。



问候语,
Steve。

解决方案

由于没有人能够回答我的问题或任何其他问题,我认为这是有效的
提供我自己的调查结果作为答案。


我能够找到重要的方法调用,这是自定义UI实现所需的。
它们基本上位于两个接口 RoomUpdateListener RoomStatusUpdateListener 中,并且需要提供给 RoomConfig.Builder



游戏的生命周期如下所示:

第1步


  • 通过


      Games.RealTimeMultiplayer.create(mGoogleApiClient,rtmConfigBuilder.build());



      第2步


      • RoomUpdateListener:onRoomCreated 客户端尝试创建实时房间。
      • 第3步


        • RoomStatusUpdateListener:onPeerJoined 当一个或多个同行参与者加入房间时调用。

        • RoomStatusUpdateListener:onRoomConnecting 一个或多个参与者已加入该会议室并已启动建立对等连接的过程

        • RoomStatusUpdateListener:onP2PConnected 客户端已成功连接到对等参与者。 c $ c> RoomStatusUpdateListener:onConnectedToRoom 客户端连接到房间中已连接的设备。
        • RoomStatusUpdateListener:onPeersConnected 当一个或多个同行参与者加入房间时调用。



        第4步




        • RoomUpdateListener:onRoomConnected 实时房间中的所有参与者都已完全连接。



        就是这样。现在参与者已连接并可通过 Games.RealTimeMultiplayer.sendReliableMessage 和其他发送方法发送消息。


        I am about to implement a real-time-multiplayer for my android application with the google play games services and got some problems to listen to room updates. Iam not that experienced, so please forgive the possible understanding problems.

        My intention is that I need to get informed, if anybody has joined my recently created room or created another room himself with the same variant as my room.

        I have tried to listen on the RoomStatusUpdateListener, but after I created a room, this listener never get called and I wonder why. What does get called, is the RoomUpdateListener, but it contains not the callback methods which I need.

        I know that it is recommended to use the android build in waiting room ui and to use Games.RealTimeMultiplayer.getWaitingRoomIntent() to start an activityForResult, but I need to create something like my own waiting room and do not know how. Apparently the google activity (the waiting) room does get informed about changes, so there must be a way to observe these.

        As far as I can tell, Iam trying to do something like:

        1. creating multiple rooms with different variants
        2. listen on any room for updates (a player joins or created the same room)
        3. join the room with the update from step 2.

        Does anybody have an idea how I can achieve that? I would be so glad. Sorry for my bad english.

        Greetings , Steve.

        解决方案

        Since nobody was able to answer my question or whatever, I think it is valid to provide my result of investigation as an answer myself.

        I was able to find the important method calls, which are needed for a custom UI implementation. They are basically located in the two interfaces RoomUpdateListener and RoomStatusUpdateListener and need to be provided to the RoomConfig.Builder.

        The lifecycle of a game is like the following:

        Step 1

        • create the room via

        Games.RealTimeMultiplayer.create(mGoogleApiClient, rtmConfigBuilder.build());

        Step 2

        • RoomUpdateListener: onRoomCreated The client attempts to create a real-time room.

        Step 3

        • RoomStatusUpdateListener: onPeerJoined Called when one or more peer participants join a room.
        • RoomStatusUpdateListener: onRoomConnecting One or more participants have joined the room and have started the process of establishing peer connections
        • RoomStatusUpdateListener: onP2PConnected Client is successfully connected to a peer participant.
        • RoomStatusUpdateListener: onConnectedToRoom The client is connected to the connected set in a room.
        • RoomStatusUpdateListener: onPeersConnected Called when one or more peer participants join a room.

        Step 4

        • RoomUpdateListener: onRoomConnected All the participants in a real-time room are fully connected.

        That's it. Now the participants are connected and can send messages via Games.RealTimeMultiplayer.sendReliableMessage and the other send methods.

        这篇关于Google-Play-Services:创建自定义候车室用户界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆