我们如何得知谁在实时GPG中统一发起了会议室?

时间:2019-03-23 09:15:55

标签: unity3d google-play-games real-time-multiplayer

我想检查谁是实时启动Google Play游戏APi的房间的当前玩家。但是由于在每个播放器设备上都会调用Onroomconnected,因此我们将无法实时获得它?那么我们怎么知道是谁发起了房间或仅通过单个设备而不是每个玩家发送消息,因为这是实时游戏?

我尝试获取房间的信息,但是房间创建者ID和参与者ID与我检查的有所不同。我也尝试使用用户邮件,但无法这样做。

void RealTimeMultiplayerListener.OnRoomConnected(bool success){
    // game Main Scene here
    if(success){
        // Successfully connected to room!
        // ...start playing game...
        strMessage.text = "room connected";    
        Participant myself = PlayGamesPlatform.Instance.RealTime.GetSelf();
        Debug.Log("My participant ID is " + myself.ParticipantId);
        List<Participant> participants = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants();
        string players = "";
        for (int participantsCounter = 0; participantsCounter < participants.Count; participantsCounter++){
                players += participants[participantsCounter];
        }
        sendMessage("Players",players); // Send it from a single player 
    }else{
        // Error!
        // ...show error message to user...
        strMessage.text = "room connect Fail.";

    }

}

0 个答案:

没有答案