private void saveIglooLayoutChanges(System.Action onSyncStopped = null, IIglooUpdateLayoutErrorHandler errorHandler = null) { bool flag = false; foreach (SceneLayoutData item in sceneLayoutDataModified.Keys.ToList()) { if (!sceneLayoutDataModified[item]) { continue; } MutableSceneLayout mutableSceneLayout = new MutableSceneLayout(); ConvertToMutableSceneLayout(mutableSceneLayout, item); foreach (ExtraLayoutInfoLoader extraLayoutInfoLoader in extraLayoutInfoLoaders) { ExtraLayoutInfo extraLayoutInfo = extraLayoutInfoLoader(); mutableSceneLayout.extraInfo[extraLayoutInfo.Key] = extraLayoutInfo.Value; } EventHandlerDelegate <IglooServiceEvents.IglooLayoutUpdated> successHandler = null; successHandler = delegate { Service.Get <EventDispatcher>().RemoveListener(successHandler); onSyncStopped.InvokeSafe(); return(false); }; Service.Get <EventDispatcher>().AddListener(successHandler); IIglooUpdateLayoutErrorHandlerWrapper errorHandler2 = new IIglooUpdateLayoutErrorHandlerWrapper(successHandler, errorHandler); Service.Get <INetworkServicesManager>().IglooService.UpdateIglooLayout(item.LayoutId, mutableSceneLayout, errorHandler2); sceneLayoutDataModified[item] = false; flag = true; } if (!flag) { onSyncStopped.InvokeSafe(); } }
public void UpdateIglooLayout(long layoutId, MutableSceneLayout sceneLayout, IIglooUpdateLayoutErrorHandler errorHandler = null) { APICall <UpdateIglooLayoutOperation> aPICall = clubPenguinClient.IglooApi.UpdateIglooLayout(layoutId, sceneLayout); aPICall.OnResponse += onUpdateIglooLayout; aPICall.OnError += delegate(UpdateIglooLayoutOperation op, HttpResponse HttpResponse) { if (errorHandler != null) { errorHandler.OnUpdateLayoutError(); } else { handleCPResponseError(op, HttpResponse); } }; aPICall.Execute(); }
public void StopSyncingSceneLayoutData(SceneLayoutData sceneLayoutData, System.Action onSyncStopped, IIglooUpdateLayoutErrorHandler errorHandler = null) { if (!sceneLayoutDataModified.ContainsKey(sceneLayoutData)) { onSyncStopped.InvokeSafe(); return; } saveIglooLayoutChanges(onSyncStopped, errorHandler); sceneLayoutData.SceneLayoutDataUpdated -= onSceneLayoutDataUpdated; sceneLayoutDataModified.Remove(sceneLayoutData); }
public IIglooUpdateLayoutErrorHandlerWrapper(EventHandlerDelegate <IglooServiceEvents.IglooLayoutUpdated> successHandler, IIglooUpdateLayoutErrorHandler errorHandler) { this.successHandler = successHandler; this.errorHandler = errorHandler; }