示例#1
0
        private void FindEqualVersionMatch(TurnBasedMatch match, Action <bool> onFailure,
                                           Action <NativeTurnBasedMatch> onVersionMatch)
        {
            mTurnBasedManager.GetMatch(match.MatchId, response =>
            {
                using (var foundMatch = response.Match())
                {
                    if (foundMatch == null)
                    {
                        Logger.e(string.Format("Could not find match {0}", match.MatchId));
                        onFailure(false);
                        return;
                    }

                    if (foundMatch.Version() != match.Version)
                    {
                        Logger.e(string.Format("Attempted to update a stale version of the " +
                                               "match. Expected version was {0} but current version is {1}.",
                                               match.Version, foundMatch.Version()));
                        onFailure(false);
                        return;
                    }

                    onVersionMatch(foundMatch);
                }
            });
        }
 public void GetMatch(string matchId, Action <bool, TurnBasedMatch> callback)
 {
     mTurnBasedManager.GetMatch(matchId, response =>
     {
         using (var foundMatch = response.Match())
         {
             if (foundMatch == null)
             {
                 Logger.e(string.Format("Could not find match {0}", matchId));
                 callback(false, null);
             }
             else
             {
                 callback(true, foundMatch.AsTurnBasedMatch(mNativeClient.GetUserId()));
             }
         }
     });
 }
 private void FindEqualVersionMatch(GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch match, Action <bool> onFailure, Action <NativeTurnBasedMatch> onVersionMatch)
 {
     mTurnBasedManager.GetMatch(match.MatchId, delegate(TurnBasedManager.TurnBasedMatchResponse response)
     {
         using (NativeTurnBasedMatch nativeTurnBasedMatch = response.Match())
         {
             if (nativeTurnBasedMatch == null)
             {
                 Logger.e($"Could not find match {match.MatchId}");
                 onFailure(false);
             }
             else if (nativeTurnBasedMatch.Version() != match.Version)
             {
                 Logger.e($"Attempted to update a stale version of the match. Expected version was {match.Version} but current version is {nativeTurnBasedMatch.Version()}.");
                 onFailure(false);
             }
             else
             {
                 onVersionMatch(nativeTurnBasedMatch);
             }
         }
     });
 }