コード例 #1
0
 public override void MatchDidReceiveDataForRecipient(GKMatch match, NSData data, GKPlayer recipient, GKPlayer remotePlayer)
 {
     if (recipient != null && recipient.Equals(GKLocalPlayer.LocalPlayer))
     {
         MatchDidReceiveData(match, data, remotePlayer);
     }
 }
コード例 #2
0
            public override void PlayerDidChangeConnectionState(GKMatch match, GKPlayer player, GKPlayerConnectionState state)
            {
                RuntimeHelper.RunOnMainThread(() =>
                {
                    var listener = mClient.mCurrentListener;

                    if (listener == null || match == null || player == null)
                    {
                        return;
                    }

                    if (player.Equals(GKLocalPlayer.LocalPlayer))
                    {
                        // In reality, this never runs because GameKit never reports
                        // connection state changes of local player.
                        if (state == GKPlayerConnectionState.Disconnected)
                        {
                            listener.OnLeftRoom();
                        }
                    }
                    else
                    {
                        if (state == GKPlayerConnectionState.Connected)
                        {
                            listener.OnPeersConnected(new string[] { player.PlayerID });
                            ReportRoomSetupProgress(listener, match, null, true);
                        }
                        else if (state == GKPlayerConnectionState.Disconnected)
                        {
                            if (match.ExpectedPlayerCount > 0)      // player leaves during room setup
                            {
                                listener.OnParticipantLeft(Participant.FromGKPlayer(player, state.ToParticipantStatus(), false));
                                ReportRoomSetupProgress(listener, match, null, true);
                            }
                            else        // player disconnected after match setup has completed
                            {
                                listener.OnPeersDisconnected(new string[] { player.PlayerID });
                            }
                        }
                    }
                });
            }