public void LoadState(int slot, OnStateLoadedListener listener) { GooglePlayGames.OurUtils.Logger.d("LoadState, slot=" + slot); using (var apiClient = GetApiClient(mServices)) { CallAppState(apiClient, "load", new OnStateResultProxy(mServices, listener), slot); } }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { Logger.d("IOSClient.UpdateState slot " + slot + ", " + data.Length + " bytes"); mStateLoadedListener[slot] = listener; SaveCloudCacheFile(slot, data); GPGSUpdateState(slot, data, data.Length, UpdateStateCallback, StateConflictCallback); }
public void LoadState(int slot, OnStateLoadedListener listener) { if (listener != null) { listener.OnStateLoaded(false, slot, null); } }
// called from game thread public void LoadState(int slot, OnStateLoadedListener listener) { Logger.d("AndroidClient.LoadState, slot=" + slot); CallAppStateClientApi("load state slot=" + slot, (AndroidJavaObject c) => { OnStateLoadedProxy proxy = new OnStateLoadedProxy(this, listener); c.Call("loadState", proxy, slot); }, null); }
// called from game thread public void LoadState(int slot, OnStateLoadedListener listener) { Logger.d("AndroidClient.LoadState, slot=" + slot); CallClientApi("load state slot=" + slot, () => { OnStateResultProxy proxy = new OnStateResultProxy(this, listener); mGHManager.CallGmsApiWithResult("appstate.AppStateManager", null, "load", proxy, slot); }, null); }
// called from game thread. This is ONLY called internally (OnStateLoadedProxy // calls this). This is not part of the IPlayGamesClient interface. internal void ResolveState(int slot, string resolvedVersion, byte[] resolvedData, OnStateLoadedListener listener) { Logger.d(string.Format("AndroidClient.ResolveState, slot={0}, ver={1}, " + "data={2}", slot, resolvedVersion, resolvedData)); CallAppStateClientApi("resolve state slot=" + slot, (AndroidJavaObject c) => { c.Call("resolveState", new OnStateLoadedProxy(this, listener), slot, resolvedVersion, resolvedData); }, null); }
private void ResolveState(int slot, string resolvedVersion, byte[] resolvedData, OnStateLoadedListener listener) { GooglePlayGames.OurUtils.Logger.d(string.Format("AndroidClient.ResolveState, slot={0}, ver={1}, " + "data={2}", slot, resolvedVersion, resolvedData)); using (var apiClient = GetApiClient(mServices)) { CallAppState(apiClient, "resolve", new OnStateResultProxy(mServices, listener), slot, resolvedVersion, resolvedData); } }
// called from game thread. This is ONLY called internally (OnStateLoadedProxy // calls this). This is not part of the IPlayGamesClient interface. internal void ResolveState(int slot, string resolvedVersion, byte[] resolvedData, OnStateLoadedListener listener) { Logger.d(string.Format("AndroidClient.ResolveState, slot={0}, ver={1}, " + "data={2}", slot, resolvedVersion, resolvedData)); CallClientApi("resolve state slot=" + slot, () => { mGHManager.CallGmsApiWithResult("appstate.AppStateManager", null, "resolve", new OnStateResultProxy(this, listener), slot, resolvedVersion, resolvedData); }, null); }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { Logger.d("UpdateState, slot=" + slot); using (var apiClient = GetApiClient(mServices)) { AppStateManager.CallStatic("update", apiClient, slot, data); } // Updates on android always succeed - at very least they are written to local disk. if (listener != null) { PlayGamesHelperObject.RunOnGameThread(() => listener.OnStateSaved(true, slot)); } }
// called from game thread public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { Logger.d(string.Format("AndroidClient.UpdateState, slot={0}, data={1}", slot, Logger.describe(data))); CallAppStateClientApi("update state, slot=" + slot, (AndroidJavaObject c) => { c.Call("updateState", slot, data); }, null); // On Android, cloud writes always succeed (because, at worst, they get cached // locally to send to the cloud later) listener.OnStateSaved(true, slot); }
// called from game thread public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { Logger.d(string.Format("AndroidClient.UpdateState, slot={0}, data={1}", slot, Logger.describe(data))); CallClientApi("update state, slot=" + slot, () => { mGHManager.CallGmsApi("appstate.AppStateManager", null, "update", slot, data); }, null); // On Android, cloud writes always succeeds (because, in the worst case, // data gets cached locally to send to the cloud later) listener.OnStateSaved(true, slot); }
public void LoadState(int slot, OnStateLoadedListener listener) { Logger.d("AndroidClient.LoadState, slot=" + slot); this.CallClientApi("load state slot=" + slot, delegate { OnStateResultProxy callbackProxy = new OnStateResultProxy(this, listener); this.mGHManager.CallGmsApiWithResult("appstate.AppStateManager", null, "load", callbackProxy, new object[] { slot }); }, null); }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { GooglePlayGames.OurUtils.Logger.d("UpdateState, slot=" + slot); using (var apiClient = GetApiClient(mServices)) { AppStateManager.CallStatic("update", apiClient, slot, data); } // Updates on android always succeed - at very least they are written to local disk. if (listener != null) { PlayGamesHelperObject.RunOnGameThread(() => listener.OnStateSaved(true, slot)); } }
public void LoadState(int slot, OnStateLoadedListener listener) { Misc.CheckNotNull(listener); lock (GameServicesLock) { if (mAuthState != AuthState.Authenticated) { Logger.e("You can only call LoadState after the user has successfully logged in"); listener.OnStateLoaded(false, slot, null); } mAppStateClient.LoadState(slot, listener); } }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { Logger.d(string.Format("AndroidClient.UpdateState, slot={0}, data={1}", slot, Logger.describe(data))); this.CallClientApi("update state, slot=" + slot, delegate { this.mGHManager.CallGmsApi("appstate.AppStateManager", null, "update", new object[] { slot, data }); }, null); listener.OnStateSaved(true, slot); }
/// <summary> /// Loads app state (cloud save) data from the server. /// </summary> /// <param name='slot'> /// The app state slot number. The exact number of slots and their size can be seen /// in the Google Play Games documentation. Slot 0 is always available, and is at /// least 128K long. /// </param> /// <param name='callbacks'> /// The callbacks to call when the state is loaded, or when a conflict occurs. /// </param> public void LoadState(int slot, OnStateLoadedListener listener) { if (!IsAuthenticated()) { Logger.e("LoadState can only be called after authentication."); if (listener != null) { listener.OnStateLoaded(false, slot, null); } return; } mClient.LoadState(slot, listener); }
/// <summary> /// Writes app state (cloud save) data to the server. /// </summary> /// <param name='slot'> /// The app state slot number. The exact number of slots and their size can be seen /// in the Google Play Games documentation. Slot 0 is always available, and is at /// least 128K long. /// </param> /// <param name='data'> /// The data to write. /// </param> public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { if (!IsAuthenticated()) { Logger.e("UpdateState can only be called after authentication."); if (listener != null) { listener.OnStateSaved(false, slot); } return; } mClient.UpdateState(slot, data, listener); }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { Misc.CheckNotNull(listener); lock (GameServicesLock) { if (mAuthState != AuthState.Authenticated) { // Logger.e("You can only call UpdateState after the user has successfully logged in"); listener.OnStateSaved(false, slot); } mAppStateClient.UpdateState(slot, data, listener); } }
private static void UpdateStateCallback(bool success, int slot) { OnStateLoadedListener listener = GetListener(slot); Logger.d("IOSClient.UpdateStateCallback, slot=" + slot + ", success=" + success); if (null != listener) { Logger.d("IOSClient.UpdateStateCallback calling OnSLL.OnStateSaved"); listener.OnStateSaved(success, slot); } else { Logger.d("IOSClient.UpdateStateCallback: no OnSLL to call!"); } }
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))); }
private static void LoadStateCallback(bool success, int slot, IntPtr dataBuf, int dataSize) { string prefix = "IOSClient.LoadStateCallback "; Logger.d(prefix + " success=" + success + ", slot=" + slot + " dataBuf=" + dataBuf + " dataSize=" + dataSize); byte[] data = null; if (success) { if (dataBuf.ToInt32() != 0) { data = new byte[dataSize]; Marshal.Copy(dataBuf, data, 0, dataSize); sInstance.SaveCloudCacheFile(slot, data); } } else { // Cloud load failed... but don't despair! Do we have the data in local cache? Logger.d(prefix + "Cloud load failed. Trying to load local cache."); byte[] localCache = sInstance.LoadCloudCacheFile(slot); if (localCache != null) { // no local cache, so we have to report a failure. Logger.d(prefix + "Local cache not present. Reporting failure."); } else { // we have data in local cache, so report success instead of failure, // and return that data. Logger.d(prefix + "Loaded from local cache, so reporting success."); data = localCache; success = true; } } OnStateLoadedListener callback = GetListener(slot); if (callback != null) { Logger.d(prefix + "calling OnStateLoadedListener with " + (success ? "success" : "failure")); callback.OnStateLoaded(success, slot, data); } }
internal OnStateResultProxy(GameServices services, OnStateLoadedListener listener) : base(ResultCallbackClassname) { mServices = Misc.CheckNotNull(services); mListener = listener; }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { LogUsage(); }
private void ResolveState(int slot, string resolvedVersion, byte[] resolvedData, OnStateLoadedListener listener) { Logger.d(string.Format("AndroidClient.ResolveState, slot={0}, ver={1}, " + "data={2}", slot, resolvedVersion, resolvedData)); using (var apiClient = GetApiClient(mServices)) { CallAppState(apiClient, "resolve", new OnStateResultProxy(mServices, listener), slot, resolvedVersion, resolvedData); } }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { throw new NotImplementedException(mMessage); }
internal OnStateResultProxy(GooglePlayGames.Native.PInvoke.GameServices services, OnStateLoadedListener listener) { this.\u002Ector("com.google.android.gms.common.api.ResultCallback"); this.mServices = Misc.CheckNotNull <GooglePlayGames.Native.PInvoke.GameServices>(services); this.mListener = listener; }
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); }
private static int StateConflictCallback(int slot, IntPtr localBufPtr, int localDataSize, IntPtr serverBufPtr, int serverDataSize, IntPtr resolvBufPtr, int resolvBufCap) { string prefix = "IOSClient.StateConflictCallback "; Logger.d(prefix + "slot " + slot + " " + "localbuf " + localBufPtr + " (" + localDataSize + " bytes); " + "serverbuf " + serverBufPtr + " (" + serverDataSize + " bytes); " + "resolvbuf " + resolvBufPtr + " (capacity " + resolvBufCap + ")"); byte[] localData = null; byte[] serverData = null; if (localBufPtr.ToInt32() != 0) { localData = new byte[localDataSize]; Marshal.Copy(localBufPtr, localData, 0, localDataSize); } if (serverBufPtr.ToInt32() != 0) { serverData = new byte[serverDataSize]; Marshal.Copy(serverBufPtr, serverData, 0, serverDataSize); } OnStateLoadedListener listener = GetListener(slot); byte[] resolvData = null; if (OurUtils.Misc.BuffersAreIdentical(localData, serverData)) { Logger.d(prefix + "Bypassing fake conflict " + "(local data is IDENTICAL to server data)."); resolvData = localData != null ? localData : serverData; } else if (listener != null) { Logger.d(prefix + "calling OnSLL.OnStateConflict."); resolvData = listener.OnStateConflict(slot, localData, serverData); Logger.d(prefix + " resolvData has " + resolvData.Length + " bytes"); if (resolvData.Length > resolvBufCap) { Logger.e("Resolved data length is " + resolvData.Length + " which exceeds " + "resolved buffer capacity " + resolvBufCap); resolvData = null; } } else { Logger.d(prefix + "no listener, so choosing local data."); } if (resolvData == null) { // fallback Logger.w("Using fallback strategy due to unexpected resolution."); resolvData = localData != null ? localData : serverData; if (resolvData == null) { Logger.w("ERROR: unexpected cloud conflict where all data sets are null. " + "Fixing by storing byte[1] { 0 }."); resolvData = new byte[1] { 0 }; } } int len = resolvBufCap < resolvData.Length ? resolvBufCap : resolvData.Length; Logger.d(prefix + "outputting " + len + " bytes to resolved buffer."); Marshal.Copy(resolvData, 0, resolvBufPtr, len); Logger.d(prefix + "finishing up."); return(len); }
public virtual void LoadState(int slot, OnStateLoadedListener listener) { throw new NotSupportedException("unsupported"); }
internal OnStateResultProxy(AndroidClient androidClient, OnStateLoadedListener listener) : base(JavaUtil.ResultCallbackClass) { mListener = listener; mAndroidClient = androidClient; }
internal OnStateLoadedProxy(AndroidClient androidClient, OnStateLoadedListener listener) : base("com.google.android.gms.appstate.OnStateLoadedListener") { mListener = listener; mAndroidClient = androidClient; }
public void LoadState(int slot, OnStateLoadedListener listener) { Logger.d("IOSClient.LoadState slot=" + slot); mStateLoadedListener[slot] = listener; GPGSLoadState(slot, LoadStateCallback, StateConflictCallback); }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { throw new NotImplementedException("App State is not supported on this platform."); }
public void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { Misc.CheckNotNull(listener); lock (GameServicesLock) { if (mAuthState != AuthState.Authenticated) { Logger.e("You can only call UpdateState after the user has successfully logged in"); listener.OnStateSaved(false, slot); } mAppStateClient.UpdateState(slot, data, listener); } }
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); }
public void LoadState(int slot, OnStateLoadedListener listener) { throw new NotImplementedException(mMessage); }
public virtual void UpdateState(int slot, byte[] data, OnStateLoadedListener listener) { throw new NotSupportedException("unsupported"); }
public void LoadState(int slot, OnStateLoadedListener listener) { LogUsage(); if (listener != null) { listener.OnStateLoaded(false, slot, null); } }