void IDbType <IDbUser> .Create() { var user = new ParseUser { Username = ((IDbUser)this).UserLogin, Password = ((IDbUser)this).Password }; var callback = new Action(() => { ((IDbUser)this).Id = user.ObjectId; DbUser = this; }); CoreContext.StartCoroutine(RunRequest <IDbUser>(user.SignUpAsync(), ((IDbUser)this).ItemHasBeenCreatedCommandName, callback)); }
private void DeleteItemRequest <T>(Action callback = null) where T : IDbType <T> { var query = ParseObject.GetQuery(GetParseClassName <T>()); var task = query.GetAsync(((T)(IDbService)this).Id); var act = new Action(() => { var parseObject = task.Result; CoreContext.StartCoroutine(RunRequest <T>(parseObject.DeleteAsync(), ((T)(IDbService)this).ItemHasBeenDeletedCommandName, callback)); }); CoreContext.StartCoroutine(RunRequest <T>(task, null, act)); }
private void GetItemRequest <T>(Action callback = null) where T : IDbType <T> { var query = ParseObject.GetQuery(GetParseClassName <T>()); var task = query.GetAsync(((T)(IDbService)this).Id); var act = new Action(() => { UpdateFields <T>(task.Result); if (callback != null) { callback(); } }); CoreContext.StartCoroutine(RunRequest <T>(task, ((T)(IDbService)this).ItemHasBeenGottenCommandName, act)); }
private void CreateItemRequest <T>(Action callback = null) where T : IDbType <T> { var parseObject = new ParseObject(GetParseClassName <T>()); UpdateFields <T>(parseObject); var act = new Action(() => { ((T)(IDbService)this).Id = parseObject.ObjectId; if (callback != null) { callback(); } }); CoreContext.StartCoroutine(RunRequest <T>(parseObject.SaveAsync(), ((T)(IDbService)this).ItemHasBeenCreatedCommandName, act)); }
public NetworkingCore() { CoreContext.StartCoroutine(TestConnection()); InitSocialNetwork(); }
public override void Execute() { CoreContext.StartCoroutine(CreateDbInitData(NetworkingCore.IsThereConnection ? 0 : NetworkingCore.PING_DELTA_TIME + 1)); }
public void SaveUserData() { var tagIdList = new List <string>(); var tagEnabledList = new List <bool>(); var tagLastSyncDateList = new List <double>(); var tagPriorityList = new List <int>(); var tagSpentTimeList = new List <List <string> >(); foreach (var tag in CoreContext.UserData.CurrentProfile.SubGameLevelTagArray) { if (string.IsNullOrEmpty(tag.DbId)) { continue; } var spentTimeList = new List <string>(); tag.SpentTimeArray.Where(item => item.To > tag.LastSyncDate).ToList().ForEach(x => spentTimeList.Add(GetSpentTimeJson((x)))); //Debug.Log(tag.Name + " - " + spentTimeList.Count + " - " + tag.LastSyncDate); if (spentTimeList.Count < 1) { continue; } tagSpentTimeList.Add(spentTimeList); tagIdList.Add(tag.DbId); tagEnabledList.Add(tag.IsEnabled); tagPriorityList.Add(tag.Priority); tagLastSyncDateList.Add(tag.LastSyncDate.ToOADate()); } var paramDict = new Dictionary <string, object>() { { "tag_id_list", tagIdList }, { "tag_enabled_list", tagEnabledList }, { "tag_priority_list", tagPriorityList }, { "tag_last_sync_date", tagLastSyncDateList }, { "tag_spent_time_lists", tagSpentTimeList } }; var task = ParseCloud.CallFunctionAsync <string>(UPDATE_USERDATA_FUNC_NAME, paramDict); var act = new Action(() => { CoreContext.UserData.CurrentProfile.SubGameLevelTagArray.ForEach(x => x.LastSyncDate = DateTime.UtcNow); var resDict = JsonFx.Json.JsonReader.Deserialize <Dictionary <string, object> >(task.Result); if (((object[])resDict["tag_id_list"]).Length < 1) { return; } tagIdList = new List <string>((string[])resDict["tag_id_list"]); tagEnabledList = new List <bool>((bool[])resDict["tag_enabled_list"]); tagPriorityList = new List <int>((int[])resDict["tag_priority_list"]); for (var i = 0; i < tagIdList.Count; i++) { var tag = CoreContext.UserData.CurrentProfile.SubGameLevelTagArray.FirstOrDefault(x => x.DbId == tagIdList[i]); if (tag == null) { throw new Exception("Tag doesn't exist: " + tagIdList[i]); } tag.IsEnabled = tagEnabledList[i]; tag.Priority = tagPriorityList[i]; } }); CoreContext.StartCoroutine(RunRequest <int>(task, UserDataHasBeenSavedCommandName, act)); }