Пример #1
0
        void UpdatePlayer(PlayerInfo player)
        {
            string json        = JsonConvert.SerializeObject(player, Formatting.Indented);
            string FirebaseKey = GetFirebaseKey(player);

            PlayersTable.Child(FirebaseKey).SetValue(json);
        }
Пример #2
0
        public IEnumerator runUpdateChar(string cName, int newExp, int newLevel, string stat, string perk)
        {
            createGood = false;
            Firebase fb  = Firebase.CreateNew("coop-rpg.firebaseio.com/Characters/" + cName, "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase exp = fb.Child("EXP");

            exp.OnSetSuccess += createSuccess;
            exp.SetValue(newExp);
            if (newLevel != 0)
            {
                Firebase lvl = fb.Child("LVL");
                lvl.OnSetSuccess += createSuccess;
                lvl.SetValue(newLevel);

                Firebase stats = fb.Child("stats");
                Firebase mod   = stats.Child(stat);
                mod.OnSetSuccess += createSuccess;
                mod.OnGetSuccess += GetJson;
                mod.GetValue();
                yield return(new WaitForSeconds(3f));

                //Debug.Log(tempJson);
                //int temp = int.Parse(tempJson); // Why is this here? It'll just cause FormatExceptions if parsing letters or invalid numbers
                //mod.SetValue(temp + 1);
                Firebase perkFB = fb.Child("perks");
                perkFB.OnSetSuccess += createSuccess;
                perkFB.OnGetSuccess += GetJson;
                perkFB.GetValue();
                yield return(new WaitForSeconds(3f));

                tempJson = tempJson.Substring(1, tempJson.Length - 2);
                perkFB.SetValue(tempJson + ";" + perk);
            }
        }
Пример #3
0
 private void SetupRefs()
 {
     _rootRef     = Firebase.CreateNew("tubeman-677a6.firebaseio.com", "GV6eYkao7ZXQzG5D3h3PsnFeJGLZt0YGtnktHBmo");
     _appStateRef = _rootRef.Child("appState", true);
     _winnerRef   = _rootRef.Child("winner", true);
     _usersRef    = _rootRef.Child("users", true);
     _tubeman1    = new ServerTubeman().Setup(tubeman1UI, "tubeman1", _rootRef);
     _tubeman2    = new ServerTubeman().Setup(tubeman2UI, "tubeman2", _rootRef);
 }
Пример #4
0
 public ServerTubeman Setup(TubemanUI ui, string key, Firebase rootRef)
 {
     _ui      = ui;
     _rootRef = rootRef.Child(key, true);
     _nameRef = _rootRef.Child("name", true);
     _oddsRef = _rootRef.Child("odds", true);
     _potRef  = _rootRef.Child("pot", true);
     return(this);
 }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        textMesh.text = "";

        firebase  = Firebase.CreateNew("samplefirebasecsharp.firebaseio.com");
        frb_child = firebase.Child("key14").Child("key21");

        DoDebug("Firebase endpoint: " + firebase.Endpoint);
        DoDebug("Firebase key: " + firebase.Key);
        DoDebug("Firebase fullKey: " + firebase.FullKey);
        DoDebug("Firebase child key: " + frb_child.Key);
        DoDebug("Firebase child fullKey: " + frb_child.FullKey);

        firebase.OnFetchSuccess  += GetOKHandler;
        firebase.OnFetchFailed   += GetFailHandler;
        firebase.OnUpdateSuccess += SetOKHandler;
        firebase.OnUpdateFailed  += SetFailHandler;
        firebase.OnPushSuccess   += PushOKHandler;
        firebase.OnPushFailed    += PushFailHandler;

        frb_child.OnDeleteSuccess += DelOKHandler;
        frb_child.OnDeleteFailed  += DelFailHandler;


        Dictionary <string, object> dict1 = new Dictionary <string, object>();

        dict1.Add("key11", false);
        dict1.Add("key12", 0.123);
        dict1.Add("key13", 1000);

        Dictionary <string, object> dict2 = new Dictionary <string, object>();

        dict2.Add("key21", "this will be deleted later");
        dict2.Add("key22", "dkrprasetya.github.com/firebase-csharp");

        dict1.Add("key14", dict2);

        // NOTE:
        // Wrap your firebase methods with Unity's coroutine manually or use Firebase.ToCoroutine() to make it Asynchronus
        // if not, your script will wait until the method's completed

        //// Test #1: Set & Get
        StartCoroutine(Firebase.ToCoroutine(firebase.SetValue, dict1));
        StartCoroutine(Firebase.ToCoroutine(firebase.GetValue));

        //// Test #2: Set child & get with manual coroutine
        StartCoroutine(TestCoroutine());

        //// Test #3: Push value (with json string) & get with FirebaseParam parameter
        firebase.Child("Messages").Push("{ name: \"dikra\", message: \"awesome!\"}", true); // note that the push action handler is not called, as the action is assigned only to current key, not to its child
        StartCoroutine(Firebase.ToCoroutine(firebase.GetValue, FirebaseParam.Empty.Shallow().OrderByKey()));

        //// Test #4: Delete value & get with string parameter
        StartCoroutine(Firebase.ToCoroutine(firebase.Child("key12").Delete));
        StartCoroutine(Firebase.ToCoroutine(frb_child.Delete));
        StartCoroutine(Firebase.ToCoroutine(firebase.GetValue, "print=pretty"));
    }
Пример #6
0
    public void WriteGameDataToFirebase()
    {
        Dictionary <string, object> fbGame = new Dictionary <string, object>();

//        fbGame.Add("code", game.code);
        fbGame.Add("playerPosition", gameManager.game.playerPosition);

        string json = Newtonsoft.Json.JsonConvert.SerializeObject(fbGame);

        firebaseQueue.AddQueueUpdate(firebase.Child(gameManager.game.code, true), json);
    }
Пример #7
0
        public void getQuestions()
        {
            // On se place au niveau de la collection "questions"
            Firebase questionFirebase = firebase.Child("questions");

            // On ajoute quelques callbacks savoir si tout ce passe bien ou pas.
            questionFirebase.OnGetSuccess += GetOKHandler;
            questionFirebase.OnGetFailed  += GetFailHandler;

            questionFirebase.GetValue();
        }
Пример #8
0
    public void CreateNewGameWhite()
    {
        SceneManager.LoadScene("CreateScene", LoadSceneMode.Single);
        TimeSpan t = DateTime.UtcNow - DateTime.Today;
        string   secondsSinceToday = ((int)t.TotalSeconds).ToString();

        firebase.Child("Test").Push("{ \"turn\": \"0\", \"datafrom\": \"connect!\", \"datato\": \"connect\", \"time\": " + secondsSinceToday + "}", true);
        // Method signature: void UpdateFailedHandler(Firebase sender, FirebaseError err)
        //SceneManager.LoadScene("GameScene", LoadSceneMode.Single);
        //firebase.GetValue("print=pretty");
        SceneManager.LoadScene("GameSceneWhite", LoadSceneMode.Single);
    }
Пример #9
0
        public Task <(Firebase, DataSnapshot)> PushStateToFirebaseAsync(WheatState state)
        {
            Init();
            var fbNode = fbRoot.Child("v1");
            var result = JsonUtility.ToJson(state);

            var taskCompletionSource = new TaskCompletionSource <(Firebase, DataSnapshot)>();

            fbNode.OnPushSuccess += (Firebase node, DataSnapshot pushedKeyInfo) => { taskCompletionSource.SetResult((node, pushedKeyInfo)); };;
            fbNode.OnPushFailed  += (Firebase fireBase, FirebaseError error) => { Debug.Log($"Error pushing data to firebase: {error.Message}"); taskCompletionSource.SetResult((fireBase, null)); };
            fbNode.Push(result);

            return(taskCompletionSource.Task);
        }
Пример #10
0
        private void getVals(string name)
        {
            Firebase fb    = Firebase.CreateNew("coop-rpg.firebaseio.com/Classes", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase inner = fb.Child(name).Child("baseStats");
            Firebase aFB   = inner.Child("attack");
            Firebase mFB   = inner.Child("magic");
            Firebase dFB   = inner.Child("defense");

            aFB.OnGetSuccess += GetATK;
            mFB.OnGetSuccess += GetMAG;
            dFB.OnGetSuccess += GetDEF;
            aFB.GetValue();
            mFB.GetValue();
            dFB.GetValue();
        }
Пример #11
0
        public async Task <Item> Cadastrar(Item novoItem)
        {
            var registro = await Firebase.Child($"itens/{_autenticacaoService.UserName}").PostAsync <Item>(novoItem);

            novoItem.ItemId = registro.Key;
            return(novoItem);
        }
Пример #12
0
    IEnumerator Tests()
    {
        Firebase firebase = Firebase.CreateNew(datebaseUrl, "P860mYzzDiNtxNjlD6O1B5m9vMgaNocYyKUGK4et");

        // Init callbacks
        firebase.OnGetSuccess    += GetOKHandler;
        firebase.OnGetFailed     += GetFailHandler;
        firebase.OnSetSuccess    += SetOKHandler;
        firebase.OnSetFailed     += SetFailHandler;
        firebase.OnUpdateSuccess += UpdateOKHandler;
        firebase.OnUpdateFailed  += UpdateFailHandler;
        firebase.OnPushSuccess   += PushOKHandler;
        firebase.OnPushFailed    += PushFailHandler;
        firebase.OnDeleteSuccess += DelOKHandler;
        firebase.OnDeleteFailed  += DelFailHandler;

        // Get child node from firebase, if false then all the callbacks are not inherited.
        action = firebase.Child("action", true);

        FirebaseObserver observer = new FirebaseObserver(action, 1f);

        observer.OnChange += (Firebase sender, DataSnapshot snapshot) =>
        {
            DoDebug("[OBSERVER] Last updated changed to: " + snapshot.Value <long>());
            action.GetValue();
        };
        observer.Start();


        // Unnecessarily skips a frame, really, unnecessary.
        yield return(null);

        // action.GetValue();
        StateController.Instance.StartController();
    }
Пример #13
0
    public void OnRegisterSubmit()
    {
        // complete form
        // pass match confirmPass
        if (username.text != "" && password.text != "" && confirmPassword.text != "")
        {
            if (password.text == confirmPassword.text)
            {
                string encryotPassword = Encrypt(password.text);
                string json            = "{ \"username\": \"" + username.text + "\", \"password\": \""
                                         + encryotPassword
                                         + "\",\"save\":\"1\"}";

                Debug.Log(json);
                firebase.Child("users").Push(json, true);
                SceneManager.LoadScene("Login");
            }
            else
            {
                notification(1);
            }
        }
        else if (username.text == "" || password.text == "" && confirmPassword.text != "")
        {
            notification(2);
        }
    }
Пример #14
0
    // Update is called once per frame
    IEnumerator GetFeed()
    {
        // Inits Firebase using Firebase Secret Key as Auth
        // The current provided implementation not yet including Auth Token Generation
        // If you're using this sample Firebase End,
        // there's a possibility that your request conflicts with other simple-firebase-c# user's request
        Firebase firebase = Firebase.CreateNew("surility.firebaseio.com", "cbzUEBoFQ0GulANiugnbrroxyqVgXEYPZ6yB5GU9");

        // Init callbacks
        firebase.OnGetSuccess    += GetOKHandler;
        firebase.OnGetFailed     += GetFailHandler;
        firebase.OnSetSuccess    += SetOKHandler;
        firebase.OnSetFailed     += SetFailHandler;
        firebase.OnUpdateSuccess += UpdateOKHandler;
        firebase.OnUpdateFailed  += UpdateFailHandler;
        firebase.OnPushSuccess   += PushOKHandler;
        firebase.OnPushFailed    += PushFailHandler;
        firebase.OnDeleteSuccess += DelOKHandler;
        firebase.OnDeleteFailed  += DelFailHandler;

        // Print details
        DoDebug("Firebase endpoint: " + firebase.Endpoint);
        DoDebug("Firebase key: " + firebase.Key);
        DoDebug("Firebase fullKey: " + firebase.FullKey);

        // Create a FirebaseQueue
        FirebaseQueue firebaseQueue = new FirebaseQueue();

        firebaseQueue.AddQueueGet(firebase.Child("Posts", true), FirebaseParam.Empty.OrderByChild("TimeStamp").LimitToFirst(10));

        yield return(null);
    }
Пример #15
0
        public async Task <IEnumerable <T> > GetAsync(Func <T, bool> predicate)
        {
            Func <FirebaseObject <T>, bool>           firebasePredicate = (firebaseObject) => predicate(firebaseObject.Object);
            IReadOnlyCollection <FirebaseObject <T> > collection        = await Firebase.Child(ClientOptions.Value.Child).OnceAsync <T>();

            return(collection.Where(firebasePredicate).Select(it => it.Object));
        }
Пример #16
0
        void newChar(string name, string clName)
        {
            Firebase fb = Firebase.CreateNew("coop-rpg.firebaseio.com/Characters", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");

            fb.OnSetFailed  += createFailed;
            fb.OnSetSuccess += createSuccess;
            fb.Child(name, true).SetValue("{ \"EXP\": \"1\", \"HP\": \"50\", \"LVL\": \"1\", \"class\": \"" +
                                          clName + "\", \"perks\": \"Spin-Slash1\", \"skills\":" +
                                          " \"Spin-Slash\"}", true);

            Debug.Log("basic char stuff should be firebased");


            Firebase temp = Firebase.CreateNew("coop-rpg.firebaseio.com/Characters/" + name, "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");

            temp.Child("equipment", true).SetValue("{ \"acc1\": \"NONE\", \"acc2\": \"NONE\", \"armor\": \"rag\", \"weapon\": \"stick\"}", true);

            Debug.Log("equipment should be added");


            Firebase temp2 = Firebase.CreateNew("coop-rpg.firebaseio.com/Characters/" + name, "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");


            temp2.Child("stats", true).SetValue("{ \"attack\": \"1\", \"defense\": \"1\", \"magic\": \"1\"}", true);

            Debug.Log("stats should be added");
        }
Пример #17
0
        void getClassInfo()
        {
            Firebase fb = Firebase.CreateNew("coop-rpg.firebaseio.com/Classes", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase cl = fb.Child(className);

            cl.OnGetSuccess += GetJson;
            cl.GetValue();
        }
    private void Awake()
    {
        Firebase firebase = Firebase.CreateNew(FirebaseInfo.linkConnection, FirebaseInfo.key);

        firebase.OnGetSuccess += GetOKHandler;
        firebase.OnGetFailed  += GetFailHandler;
        firebase.Child("sessions", true).GetValue();
    }
Пример #19
0
        public async Task <Item> Remover(string itemId)
        {
            var registro = await Firebase.Child($"itens/{itemId}").OnceSingleAsync <Item>();

            await Firebase.Child($"itens/{_autenticacaoService.UserName}/{itemId}").DeleteAsync();

            return(registro);
        }
Пример #20
0
        void getMonsterListJson(string cat)
        {
            Firebase fb      = Firebase.CreateNew("coop-rpg.firebaseio.com/EnemyByLvl", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase monList = fb.Child(cat);

            monList.OnGetSuccess += GetJson;
            monList.GetValue();
        }
Пример #21
0
        void newAcc(string name, string pass, string email)
        {
            Firebase fb = Firebase.CreateNew("coop-rpg.firebaseio.com/Accounts", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");

            fb.OnSetFailed  += createFailed;
            fb.OnSetSuccess += createSuccess;
            fb.Child(name, true).SetValue("{ \"characters\": \"NONE\", \"email\": \"" + email + "\", \"password\": \"" + pass + "\"}", true);
        }
Пример #22
0
        void getAccJson(string aName)
        {
            Firebase fb  = Firebase.CreateNew("coop-rpg.firebaseio.com/Accounts", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase acc = fb.Child(aName);

            acc.OnGetSuccess += GetJson;
            acc.GetValue();
        }
Пример #23
0
        void getWeapInfo(string wName)
        {
            Firebase fb  = Firebase.CreateNew("coop-rpg.firebaseio.com/ItemLU/weapons", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase wep = fb.Child(wName);

            wep.OnGetSuccess += GetJson;
            wep.GetValue();
        }
Пример #24
0
        void getArmorInfo(string arName)
        {
            Firebase fb  = Firebase.CreateNew("coop-rpg.firebaseio.com/ItemLU/armor", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase arm = fb.Child(arName);

            arm.OnGetSuccess += GetJson;
            arm.GetValue();
        }
Пример #25
0
        void getAccInfo(string accName)
        {
            Firebase fb  = Firebase.CreateNew("coop-rpg.firebaseio.com/ItemLU/accesory", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase acc = fb.Child(accName);

            acc.OnGetSuccess += GetJson;
            acc.GetValue();
        }
Пример #26
0
        void getSPerkInfo(string perkName)
        {
            Firebase fb   = Firebase.CreateNew("coop-rpg.firebaseio.com/PerkLU", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase perk = fb.Child(perkName);

            perk.OnGetSuccess += GetJson;
            perk.GetValue();
        }
Пример #27
0
        void getCharInfo(string cName)
        {
            Firebase fb    = Firebase.CreateNew("coop-rpg.firebaseio.com/Characters", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase chara = fb.Child(cName);

            chara.OnGetSuccess += GetJson;
            chara.GetValue();
        }
Пример #28
0
        public static async void UpdateLocalTasksSyncDate(string syncMail)
        {
            var server = (await Firebase.Child("UserData").Child(syncMail.Replace('.', '_')).Child("Setting").OnceAsync <SettingTable>()).Where(item => item.Object.Key == "TasksSyncDate").FirstOrDefault();
            var local  = Database.Table <SettingTable>().ToList().Where(s => s.Key == "TasksSyncDate").FirstOrDefault();

            local.Value = server.Object.Value;
            Database.Update(local);
        }
Пример #29
0
        void getSkillInfo(string skillName)
        {
            Firebase fb    = Firebase.CreateNew("coop-rpg.firebaseio.com/SkillLU", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase skill = fb.Child(skillName);

            skill.OnGetSuccess += GetJson;
            skill.GetValue();
        }
        public override async Task InitializeAsync(object navigationData)
        {
            Atv = navigationData as Atividade;
            if (Atv.Comentarios == null)
            {
                Atv.Comentarios = new ObservableRangeCollection <Comment>();
            }
            SetFirebase();
            try
            {
                Atv.Comentarios.Clear();
                var result = await Firebase.Child("comments").Child(Atv.Id).OnceAsync <Comment>();

                foreach (var i in result)
                {
                    Atv.Comentarios.Add(new Comment()
                    {
                        IdComment             = i.Key,
                        Description           = i.Object.Description,
                        IdUser                = i.Object.IdUser,
                        UserName              = i.Object.UserName,
                        IdRecommendedActivity = i.Object.IdRecommendedActivity
                    });
                }
                try
                {
                    var grade = await Firebase.Child("ratings").Child(Atv.Id).OrderByKey().EqualTo(SettingsService.IdUserAtual).LimitToFirst(1).OnceAsync <Ratting>();

                    if (grade.Count != 0)
                    {
                        foreach (var i in grade)
                        {
                            Avaliacao = i.Object.grade;
                        }
                    }
                    else
                    {
                        Avaliacao = 0;
                        alterado  = false;
                    }
                }
                catch (Exception Ex)
                {
                }
            }
            catch (Exception Ex)
            {
                await DialogService.ShowMessage("Erro ao detalhar atividade. Tente novamente mais tarde", "Erro");
            }
            finally
            {
                OnPropertyChanged(nameof(Atv));
                OnPropertyChanged(nameof(Atv.Comentarios));
                OnPropertyChanged(nameof(Atv.ReportsCount));
            }
            await base.InitializeAsync(navigationData);
        }