public void Finish(TurnBasedMatch match, byte[] data, MatchOutcome outcome,
                       Action<bool> callback)
        {
            callback = Callbacks.AsOnGameThreadCallback(callback);
            FindEqualVersionMatch(match, callback, foundMatch =>
                {
                    ParticipantResults results = foundMatch.Results();

                    foreach (string participantId in outcome.ParticipantIds)
                    {
                        Types.MatchResult matchResult =
                            ResultToMatchResult(outcome.GetResultFor(participantId));
                        uint placing = outcome.GetPlacementFor(participantId);

                        if (results.HasResultsForParticipant(participantId))
                        {
                            // If the match already has results for this participant, make sure that they're
                            // consistent with what's already there.
                            var existingResults = results.ResultsForParticipant(participantId);
                            var existingPlacing = results.PlacingForParticipant(participantId);

                            if (matchResult != existingResults || placing != existingPlacing)
                            {
                                Logger.e(string.Format("Attempted to override existing results for " +
                                        "participant {0}: Placing {1}, Result {2}",
                                        participantId, existingPlacing, existingResults));
                                callback(false);
                                return;
                            }
                        }
                        else
                        {
                            // Otherwise, get updated results and dispose of the old ones.
                            var oldResults = results;
                            results = oldResults.WithResult(participantId, placing, matchResult);
                            oldResults.Dispose();
                        }
                    }

                    mTurnBasedManager.FinishMatchDuringMyTurn(foundMatch, data, results,
                        response => callback(response.RequestSucceeded()));
                });
        }
        public void Finish (string matchId, byte[] data, MatchOutcome outcome, Action<bool> callback)
        {
            Logger.d(string.Format("iOSTbmpClient.Finish matchId={0}, outcome={1}", matchId, outcome.ToString()));
            // We probably need to convert our match outcome into something we can read in


            var resultsOutput = new List<Dictionary<string, object>>();
            List<string> allParticipants = outcome.ParticipantIds;
            Dictionary<string, object> nextResult;
            foreach (string participantID in allParticipants) {
                Logger.d("Getting results for " + participantID);
                nextResult = new Dictionary<string, object>();
                // Maybe don't add them if their result is unset? Check with Bruno on this one
                if (outcome.GetResultFor(participantID) != MatchOutcome.ParticipantResult.Unset) {
                    nextResult["participantId"] = participantID;
                    nextResult["placing"] = outcome.GetPlacementFor(participantID);
                    nextResult["result"] = convertParticipantResultToiOSInt(outcome.GetResultFor(participantID));
                }
                resultsOutput.Add(nextResult);
            }
            string resultsAsJson = Json.Serialize(resultsOutput);
            Logger.d("JSonified results are " + resultsAsJson);

            sCallbackSuccessId++;
            sMatchSuccessCallbacks.Add(sCallbackSuccessId, callback);
            GPGSTBMPFinishMatch(matchId, data, data.Length, resultsAsJson, sCallbackSuccessId, TbmpMatchSuccessCallback);

        }
 public void Finish(string matchId, byte[] data, MatchOutcome outcome, Action<bool> callback) {
     Logger.d(string.Format("AndroidTbmpClient.Finish matchId={0}, data={1} outcome={2}",
             matchId, data == null ? "(null)" : data.Length + " bytes", outcome));
                 
     Logger.d("Preparing list of participant results as Android ArrayList.");
     AndroidJavaObject participantResults = new AndroidJavaObject("java.util.ArrayList");
     if (outcome != null) {
         foreach (string pid in outcome.ParticipantIds) {
             Logger.d("Converting participant result to Android object: " + pid);
             AndroidJavaObject thisParticipantResult = new AndroidJavaObject(
                 JavaConsts.ParticipantResultClass, pid,
                 JavaUtil.GetAndroidParticipantResult(outcome.GetResultFor(pid)),
                 outcome.GetPlacementFor(pid));
             
             // (yes, the return type of ArrayList.add is bool, strangely)
             Logger.d("Adding participant result to Android ArrayList.");
             participantResults.Call<bool>("add", thisParticipantResult);
             thisParticipantResult.Dispose();
         }
     }
     
     TbmpApiCall("tbmp finish w/ outcome", "finishMatch", callback, null, 
             matchId, data, participantResults);
 }