public void onResult(AndroidJavaObject result)
        {
            Logger.d("OnOpenResultProxy.onResult, result=" + result);

            if (result == null)
            {
                Logger.e("OnOpenResultProxy: result is null.");
                return;
            }

            int statusCode = JavaUtil.GetStatusCode(result);

            Logger.d("OnOpenResultProxy: status code is " + statusCode);

            AndroidJavaObject openedResult =
                JavaUtil.CallNullSafeObjectMethod(result, "getSnapshot");
            AndroidJavaObject conflictResult =
                JavaUtil.CallNullSafeObjectMethod(result, "getConflictingSnapshot");

            Snapshot opened   = null;
            Snapshot conflict = null;

            if (conflictResult != null)
            {
                conflict = new SnapshotAndroid(mClient, conflictResult);
                opened   = new SnapshotAndroid(mClient, openedResult);
                string conflictId = result.Call <string>("getConflictId");
                if (mListener != null)
                {
                    Logger.d("OnOpenResultProxy.onResult invoke conflict callback.");
                    PlayGamesHelperObject.RunOnGameThread(() => {
                        SnapshotAndroid r = mListener.OnSnapshotConflict(conflict, opened) as SnapshotAndroid;
                        resolveConflict(conflictId, r);
                    });
                }
            }
            else if (openedResult != null)
            {
                opened = new SnapshotAndroid(mClient, openedResult);
                if (mListener != null)
                {
                    Logger.d("OnOpenResultProxy.onResult invoke opened callback.");
                    PlayGamesHelperObject.RunOnGameThread(() => {
                        mListener.OnSnapshotOpened(statusCode, opened);
                    });
                }
            }
            else
            {
                Logger.d("OnOpenResultProxy: both openedResult and conflictResult are null!");
                if (mListener != null)
                {
                    Logger.d("OnOpenResultProxy.onResult invoke fail callback.");
                    PlayGamesHelperObject.RunOnGameThread(() => {
                        mListener.OnSnapshotOpened(statusCode, null);
                    });
                }
            }
        }
Example #2
0
            public void onResult(AndroidJavaObject result)
            {
                Logger.d("OnAchievementsLoadedResultProxy invoked");
                Logger.d("    result=" + result);
                int statusCode = JavaUtil.GetStatusCode(result);
                AndroidJavaObject androidJavaObject = JavaUtil.CallNullSafeObjectMethod(result, "getAchievements", new object[0]);

                this.mOwner.OnAchievementsLoaded(statusCode, androidJavaObject);
                if (androidJavaObject != null)
                {
                    androidJavaObject.Dispose();
                }
            }
Example #3
0
            public void onResult(AndroidJavaObject result)
            {
                Logger.d("OnAchievementsLoadedResultProxy invoked");
                Logger.d("    result=" + result);
                int statusCode = JavaUtil.GetStatusCode(result);
                AndroidJavaObject achBuffer = JavaUtil.CallNullSafeObjectMethod(result,
                                                                                "getAchievements");

                mOwner.OnAchievementsLoaded(statusCode, achBuffer);
                if (achBuffer != null)
                {
                    achBuffer.Dispose();
                }
            }
Example #4
0
        public void onResult(AndroidJavaObject result)
        {
            Logger.d("OnStateResultProxy.onResult, result=" + result);

            int statusCode = JavaUtil.GetStatusCode(result);

            Logger.d("OnStateResultProxy: status code is " + statusCode);

            if (result == null)
            {
                Logger.e("OnStateResultProxy: result is null.");
                return;
            }

            Logger.d("OnstateResultProxy: retrieving result objects...");
            AndroidJavaObject loadedResult = JavaUtil.CallNullSafeObjectMethod(result,
                                                                               "getLoadedResult");
            AndroidJavaObject conflictResult = JavaUtil.CallNullSafeObjectMethod(result,
                                                                                 "getConflictResult");

            Logger.d("Got result objects.");
            Logger.d("loadedResult = " + loadedResult);
            Logger.d("conflictResult = " + conflictResult);

            if (conflictResult != null)
            {
                Logger.d("OnStateResultProxy: processing conflict.");
                int    stateKey  = conflictResult.Call <int>("getStateKey");
                string ver       = conflictResult.Call <string>("getResolvedVersion");
                byte[] localData = ConvertByteArray(JavaUtil.CallNullSafeObjectMethod(
                                                        conflictResult, "getLocalData"));
                byte[] serverData = ConvertByteArray(JavaUtil.CallNullSafeObjectMethod(
                                                         conflictResult, "getServerData"));
                Logger.d("OnStateResultProxy: conflict args parsed, calling.");
                OnStateConflict(stateKey, ver, localData, serverData);
            }
            else if (loadedResult != null)
            {
                Logger.d("OnStateResultProxy: processing normal load.");
                int    stateKey  = loadedResult.Call <int>("getStateKey");
                byte[] localData = ConvertByteArray(JavaUtil.CallNullSafeObjectMethod(
                                                        loadedResult, "getLocalData"));
                Logger.d("OnStateResultProxy: loaded args parsed, calling.");
                OnStateLoaded(statusCode, stateKey, localData);
            }
            else
            {
                Logger.e("OnStateResultProxy: both loadedResult and conflictResult are null!");
            }
        }
            public void onResult(AndroidJavaObject result)
            {
                Logger.d("ResultProxy got result for method: " + mMethod);
                int            statusCode = JavaUtil.GetStatusCode(result);
                bool           isSuccess  = mSuccessCodes.Contains(statusCode);
                TurnBasedMatch match      = null;

                if (isSuccess)
                {
                    Logger.d("SUCCESS result from method " + mMethod + ": " + statusCode);
                    if (mMatchCallback != null)
                    {
                        Logger.d("Attempting to get match from result of " + mMethod);
                        AndroidJavaObject matchObj = JavaUtil.CallNullSafeObjectMethod(result, "getMatch");
                        if (matchObj != null)
                        {
                            Logger.d("Successfully got match from result of " + mMethod);
                            match = JavaUtil.ConvertMatch(mOwner.mClient.PlayerId, matchObj);
                            matchObj.Dispose();
                        }
                        else
                        {
                            Logger.w("Got a NULL match from result of " + mMethod);
                        }
                    }
                }
                else
                {
                    Logger.w("ERROR result from " + mMethod + ": " + statusCode);
                }

                if (mSuccessCallback != null)
                {
                    Logger.d("Invoking success callback (success=" + isSuccess + ") for " +
                             "result of method " + mMethod);
                    PlayGamesHelperObject.RunOnGameThread(() => {
                        mSuccessCallback.Invoke(isSuccess);
                    });
                }
                if (mMatchCallback != null)
                {
                    Logger.d("Invoking match callback for result of method " + mMethod + ": " +
                             "(success=" + isSuccess + ", match=" +
                             (match == null ? "(null)" : match.ToString()));
                    PlayGamesHelperObject.RunOnGameThread(() => {
                        mMatchCallback.Invoke(isSuccess, match);
                    });
                }
            }
        public void onResult(AndroidJavaObject result)
        {
            Logger.d("OnCommitResultProxy.onResult, result=" + result);

            if (result == null)
            {
                Logger.e("OnCommitResultProxy: result is null.");
                return;
            }

            int statusCode = JavaUtil.GetStatusCode(result);

            Logger.d("OnCommitResultProxy: status code is " + statusCode);

            if (mListener != null)
            {
                Logger.d("OnCommitResultProxy.onResult invoke callback.");
                PlayGamesHelperObject.RunOnGameThread(() => {
                    mListener.OnSnapshotCommitted(statusCode);
                });
            }
        }
            public void onResult(AndroidJavaObject result)
            {
                Logger.d("ResultProxy got result for method: " + this.mMethod);
                int            statusCode = JavaUtil.GetStatusCode(result);
                bool           isSuccess  = this.mSuccessCodes.Contains(statusCode);
                TurnBasedMatch match      = null;

                if (isSuccess)
                {
                    Logger.d(string.Concat(new object[]
                    {
                        "SUCCESS result from method ",
                        this.mMethod,
                        ": ",
                        statusCode
                    }));
                    if (this.mMatchCallback != null)
                    {
                        Logger.d("Attempting to get match from result of " + this.mMethod);
                        AndroidJavaObject androidJavaObject = JavaUtil.CallNullSafeObjectMethod(result, "getMatch", new object[0]);
                        if (androidJavaObject != null)
                        {
                            Logger.d("Successfully got match from result of " + this.mMethod);
                            match = JavaUtil.ConvertMatch(this.mOwner.mClient.PlayerId, androidJavaObject);
                            androidJavaObject.Dispose();
                        }
                        else
                        {
                            Logger.w("Got a NULL match from result of " + this.mMethod);
                        }
                    }
                }
                else
                {
                    Logger.w(string.Concat(new object[]
                    {
                        "ERROR result from ",
                        this.mMethod,
                        ": ",
                        statusCode
                    }));
                }
                if (this.mSuccessCallback != null)
                {
                    Logger.d(string.Concat(new object[]
                    {
                        "Invoking success callback (success=",
                        isSuccess,
                        ") for result of method ",
                        this.mMethod
                    }));
                    PlayGamesHelperObject.RunOnGameThread(delegate
                    {
                        this.mSuccessCallback(isSuccess);
                    });
                }
                if (this.mMatchCallback != null)
                {
                    Logger.d(string.Concat(new object[]
                    {
                        "Invoking match callback for result of method ",
                        this.mMethod,
                        ": (success=",
                        isSuccess,
                        ", match=",
                        (match != null) ? match.ToString() : "(null)"
                    }));
                    PlayGamesHelperObject.RunOnGameThread(delegate
                    {
                        this.mMatchCallback(isSuccess, match);
                    });
                }
            }