public void SaveReplay(ReplayMeta meta, ReplayData data)
        {
            logger.Info($"Checking for saved maps");
            string encodedMap = Encode(data.Map);
            string mapHash    = encodedMap.CalculateMd5();

            if (maps.Child("keys").Child(mapHash).OnceSingleAsync <EncodedData>().ConfigureAwait(false).GetAwaiter().GetResult()?.D != "1")
            {
                maps.Child("data").Child(mapHash).PutAsync(new EncodedData(encodedMap)).ConfigureAwait(false).GetAwaiter().GetResult();
                maps.Child("keys").Child(mapHash).PutAsync(new EncodedData("1")).ConfigureAwait(false).GetAwaiter().GetResult();
            }

            logger.Info($"Saving data for AI {meta.AiName} to Firebase");
            var resultData = datas
                             .PostAsync(new EncodedData(data.Encode()))
                             .ConfigureAwait(false).GetAwaiter()
                             .GetResult();

            logger.Info($"Data for AI {meta.AiName} saved, result is {resultData.Key}");

            meta.DataId  = resultData.Key;
            meta.MapHash = mapHash;

            logger.Info($"Saving meta for AI {meta.AiName} to Firebase");
            var resultMeta = metas.PostAsync(meta)
                             .ConfigureAwait(false).GetAwaiter()
                             .GetResult();

            logger.Info($"Meta for AI {meta.AiName} saved, result is {resultMeta.Key}");
        }
Example #2
0
 /// <inheritdoc/>
 public IObservable <Unit> Add(T item)
 {
     return(_childQuery
            .PostAsync(item)
            .ToObservable()
            .Do(MapKeyToId)
            .Select(_ => Unit.Default));
 }
Example #3
0
        private async Task Send()
        {
            await Init();

            var item = new Notification {
                IsError = false, Message = txtText.Text, Channel = "Test_Channel", Id = 1
            };

            item.CreatedOn = DateTime.Now;
            var newNode = await notifications.PostAsync(item);

            txtText.Text = "";
        }
        public async Task <bool> AddItemAsync(T item)
        {
            try
            {
                await _query
                .PostAsync(item);
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
        public void SaveReplay(ReplayMeta meta, ReplayData data)
        {
            var result = datas
                         .PostAsync(data)
                         .ConfigureAwait(false).GetAwaiter()
                         .GetResult();

            meta.DataId = result.Key;

            metas
            .PostAsync(meta)
            .ConfigureAwait(false).GetAwaiter()
            .GetResult();
        }
Example #6
0
        public async Task <bool> AddUserAsync(Users user)
        {
            try
            {
                var addedUser = await _query.PostAsync(user);

                user.Id = addedUser.Key;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return(false);
            }

            return(true);
        }
Example #7
0
        public static async Task SaveRestaurant(Restaurant restaurantAdded)
        {
            ChildQuery childQuery = firebaseClient.Child("Restaurants");

            await childQuery.PostAsync(restaurantAdded);
        }
 public async Task Add(T t)
 {
     await FirebaseClient.PostAsync(t);
 }