Beispiel #1
0
 public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener)
 {
     Logger.d("UpdateState, slot=" + (object)slot);
     using (AndroidJavaObject apiClient = AndroidAppStateClient.GetApiClient(this.mServices))
         ((AndroidJavaObject)AndroidAppStateClient.AppStateManager).CallStatic("update", new object[3]
         {
             (object)apiClient,
             (object)slot,
             (object)data
         });
     if (listener == null)
     {
         return;
     }
     PlayGamesHelperObject.RunOnGameThread((Action)(() => listener.OnStateSaved(true, slot)));
 }
Beispiel #2
0
            public void onResult(AndroidJavaObject result)
            {
                Logger.d("OnStateResultProxy.onResult, result=" + (object)result);
                int statusCode = AndroidAppStateClient.GetStatusCode(result);

                Logger.d("OnStateResultProxy: status code is " + (object)statusCode);
                if (result == null)
                {
                    Logger.e("OnStateResultProxy: result is null.");
                }
                else
                {
                    Logger.d("OnstateResultProxy: retrieving result objects...");
                    AndroidJavaObject target1 = result.NullSafeCall("getLoadedResult");
                    AndroidJavaObject target2 = result.NullSafeCall("getConflictResult");
                    Logger.d("Got result objects.");
                    Logger.d("loadedResult = " + (object)target1);
                    Logger.d("conflictResult = " + (object)target2);
                    if (target2 != null)
                    {
                        Logger.d("OnStateResultProxy: processing conflict.");
                        int    stateKey        = (int)target2.Call <int>("getStateKey", new object[0]);
                        string resolvedVersion = (string)target2.Call <string>("getResolvedVersion", new object[0]);
                        byte[] byteArray1      = AndroidAppStateClient.ToByteArray(target2.NullSafeCall("getLocalData"));
                        byte[] byteArray2      = AndroidAppStateClient.ToByteArray(target2.NullSafeCall("getServerData"));
                        Logger.d("OnStateResultProxy: conflict args parsed, calling.");
                        this.OnStateConflict(stateKey, resolvedVersion, byteArray1, byteArray2);
                    }
                    else if (target1 != null)
                    {
                        Logger.d("OnStateResultProxy: processing normal load.");
                        int    stateKey  = (int)target1.Call <int>("getStateKey", new object[0]);
                        byte[] byteArray = AndroidAppStateClient.ToByteArray(target1.NullSafeCall("getLocalData"));
                        Logger.d("OnStateResultProxy: loaded args parsed, calling.");
                        this.OnStateLoaded(statusCode, stateKey, byteArray);
                    }
                    else
                    {
                        Logger.e("OnStateResultProxy: both loadedResult and conflictResult are null!");
                    }
                }
            }
Beispiel #3
0
        private static void CallAppState(AndroidJavaObject apiClient, string methodName, AndroidJavaProxy callbackProxy, params object[] args)
        {
            AndroidJavaObject androidJavaObject = (AndroidJavaObject)((AndroidJavaObject)AndroidAppStateClient.AppStateManager).CallStatic <AndroidJavaObject>(methodName, AndroidAppStateClient.PrependApiClient(apiClient, args));

            using (androidJavaObject)
                androidJavaObject.Call("setResultCallback", new object[1]
                {
                    (object)callbackProxy
                });
        }
Beispiel #4
0
 private static void CallAppState(AndroidJavaObject apiClient, string methodName, params object[] args)
 {
     ((AndroidJavaObject)AndroidAppStateClient.AppStateManager).CallStatic(methodName, AndroidAppStateClient.PrependApiClient(apiClient, args));
 }
Beispiel #5
0
 public void LoadState(int slot, OnStateLoadedListener listener)
 {
     Logger.d("LoadState, slot=" + (object)slot);
     using (AndroidJavaObject apiClient = AndroidAppStateClient.GetApiClient(this.mServices))
         AndroidAppStateClient.CallAppState(apiClient, "load", (AndroidJavaProxy) new AndroidAppStateClient.OnStateResultProxy(this.mServices, listener), (object)slot);
 }
Beispiel #6
0
 private void ResolveState(int slot, string resolvedVersion, byte[] resolvedData, OnStateLoadedListener listener)
 {
     Logger.d(string.Format("AndroidClient.ResolveState, slot={0}, ver={1}, data={2}", (object)slot, (object)resolvedVersion, (object)resolvedData));
     using (AndroidJavaObject apiClient = AndroidAppStateClient.GetApiClient(this.mServices))
         AndroidAppStateClient.CallAppState(apiClient, "resolve", (AndroidJavaProxy) new AndroidAppStateClient.OnStateResultProxy(this.mServices, listener), (object)slot, (object)resolvedVersion, (object)resolvedData);
 }