Google-Play-Services:创建自定义候车室用户界面 [英] Google-Play-Services: Creating custom waiting room UI
问题描述
我正要为我的android应用程序实现一个实时多人游戏,并使用谷歌玩游戏
服务,并且有一些问题需要听取更新。 Iam没那么有经验,
,所以请谅解可能的理解问题。
我的意图是我需要得到消息,如果有人加入了我最近的
创建了房间,或者自己创建了另一个房间,使用与我的房间相同的变体。
我试图在RoomStatusUpdateListener上听,但是在创建房间后,
这个监听器永远不会被调用,我不知道为什么。什么被调用,是
RoomUpdateListener,但它不包含我需要的回调方法。
我知道建议使用android build在
等候室ui中,并使用Games.RealTimeMultiplayer.getWaitingRoomIntent()来
启动一个activityForResult,但我需要创建类似我自己的等候室
的东西,但不知道如何。显然,谷歌活动(等待)的房间确实获得了
的变化通知,因此必须有一种方法来观察这些变化。
据我所知,Iam试图做以下事情:
- 创建具有不同变体的多个房间
- 更新空间(玩家加入或创建同一房间)
- 通过步骤2中的更新加入房间。
有人知道我该如何做到这一点吗?
我会很高兴。抱歉,我的英语不好。
问候语,
Steve。
由于没有人能够回答我的问题或任何其他问题,我认为这是有效的
提供我自己的调查结果作为答案。
我能够找到重要的方法调用,这是自定义UI实现所需的。
它们基本上位于两个接口 RoomUpdateListener
和 RoomStatusUpdateListener
中,并且需要提供给 RoomConfig.Builder
。
游戏的生命周期如下所示:
第1步
- 通过
-
RoomUpdateListener:onRoomCreated
客户端尝试创建实时房间。 第3步 -
RoomStatusUpdateListener:onPeerJoined
当一个或多个同行参与者加入房间时调用。 -
RoomStatusUpdateListener:onRoomConnecting
一个或多个参与者已加入该会议室并已启动建立对等连接的过程 -
RoomStatusUpdateListener:onP2PConnected
客户端已成功连接到对等参与者。 c $ c> RoomStatusUpdateListener:onConnectedToRoom 客户端连接到房间中已连接的设备。
RoomStatusUpdateListener:onPeersConnected
当一个或多个同行参与者加入房间时调用。
-
RoomUpdateListener:onRoomConnected
实时房间中的所有参与者都已完全连接。 - creating multiple rooms with different variants
- listen on any room for updates (a player joins or created the same room)
- join the room with the update from step 2.
- create the room via
RoomUpdateListener: onRoomCreated
The client attempts to create a real-time room.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 connectionsRoomStatusUpdateListener: 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.RoomUpdateListener: onRoomConnected
All the participants in a real-time room are fully connected.
Games.RealTimeMultiplayer.create(mGoogleApiClient,rtmConfigBuilder.build());
第2步
第4步
就是这样。现在参与者已连接并可通过
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:
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
andRoomStatusUpdateListener
and need to be provided to theRoomConfig.Builder
.The lifecycle of a game is like the following:
Step 1
Games.RealTimeMultiplayer.create(mGoogleApiClient, rtmConfigBuilder.build());
Step 2
Step 3
Step 4
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屋!
-