Exemplo n.º 1
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);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Setups the firebase instance.
    /// </summary>
    private void setupFirebaseInstance()
    {
        //Firebase instance
        firebase = Firebase.CreateNew(settings.url, settings.apiKey);

        //Create a new queue
        queue = new FirebaseQueue(true);
    }
Exemplo n.º 3
0
    public void SetActionDONE()
    {
        // Create a FirebaseQueue
        FirebaseQueue firebaseQueue = new FirebaseQueue();


        firebaseQueue.AddQueueUpdate(action, "{\"sync\": \"DONE\"}", true);
    }
Exemplo n.º 4
0
        private void Awake()
        {
            instance = this;

            firebase      = Firebase.CreateNew(webAdress);
            firebaseQueue = new FirebaseQueue(true);

            onGetFunctions = new List <Action <String> >();
        }
    void GetCountData()
    {
        Firebase firebase = Firebase.CreateNew(firebaseID, "");
        Firebase user     = firebase.Child("rooms");

        FirebaseQueue firebaseQueue = new FirebaseQueue(true, 1, 1.0f);

        count++;

        firebaseQueue.AddQueueUpdate(user.Child(roomID), "{ \"finishCount\": \"" + count + "\"}");
    }
Exemplo n.º 6
0
        private void addItemVals()
        {
            Firebase      iLU = Firebase.CreateNew("coop-rpg.firebaseio.com/ItemLU", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            FirebaseQueue q   = new FirebaseQueue();
            //Weapon
            Firebase wCheck = iLU.Child("weapons").Child(weapon);

            Firebase wTypeFB = wCheck.Child("type");

            wTypeFB.OnGetSuccess += GetWeaponType;


            Firebase wNum = wCheck.Child("value");

            //q.AddQueueGet (wTypeFB);
            wTypeFB.GetValue();


            //Armor
            Firebase arCheck = iLU.Child("armor").Child(armor).Child("value");

            arCheck.OnGetSuccess += GetDEFHandler;
            arCheck.GetValue();
            //q.AddQueueGet(arCheck);
            //Accs
            Firebase acc1FB = iLU.Child("accesory").Child(acc1);
            Firebase acc2FB = iLU.Child("accesory").Child(acc2);
            Firebase acc1T  = acc1FB.Child("stat");
            Firebase acc2T  = acc2FB.Child("stat");

            //getAccTypes (acc1FB, acc2FB);
            acc1T.OnGetSuccess += GetAcc1Type;
            //a1.GetValue ();
            acc2T.OnGetSuccess += GetAcc2Type;

            //q.AddQueueGet (acc1FB);
            //q.AddQueueGet (acc2FB);
            acc1T.GetValue();
            acc2T.GetValue();
        }
Exemplo n.º 7
0
    IEnumerator getFirebaseBPM()
    {
        Firebase firebase = Firebase.CreateNew("https://pulsesensor-a13e2.firebaseio.com/PulseData", "RyvmMbMFgX2vxBhbv2XQDlLZhZ1Y7NOFr9E0EmYG");

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

        // Make observer on "last update" time stamp
        FirebaseObserver observer = new FirebaseObserver(lastPulseReading, 1f);

        observer.OnChange += (Firebase sender, DataSnapshot snapshot) =>
        {
            // DebugLog("[OBSERVER] Last Pulsereading changed to: " + snapshot.Value<long>());
            int newBPM = unchecked ((int)snapshot.Value <long>());

            if (lastBPM - newBPM >= 10)
            {
                bpmState = "DESCENDING";
            }
            else if (newBPM >= 100)
            {
                bpmState = "HIGH";
            }
            else
            {
                bpmState = "NEUTRAL";
            }

            lastBPM = unchecked ((int)snapshot.Value <long>());
            DebugLog(bpmState);
        };
        observer.Start();
        DebugLog("[OBSERVER] FirebaseObserver on " + lastPulseReading.FullKey + " started!");

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

        // Create a FirebaseQueue
        FirebaseQueue firebaseQueue = new FirebaseQueue(true, 3, 1f); // if _skipOnRequestError is set to false, queue will stuck on request Get.LimitToLast(-1).
    }
Exemplo n.º 8
0
        private void addClassVals(string cName)
        {
            //DoDebug("FUG: " + ClassLU.getAttack(cName));
            FirebaseQueue q  = new FirebaseQueue();
            Firebase      cl = Firebase.CreateNew("coop-rpg.firebaseio.com/Classes", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            //DoDebug("CLASS ATK: " + ClassLU.getAttack(cName));
            Firebase atk = cl.Child(cName).Child("baseStats").Child("attack");

            atk.OnGetSuccess += GetATKHandler;
            //atk.GetValue ();
            q.AddQueueGet(atk);
            Firebase def = cl.Child(cName).Child("baseStats").Child("defense");

            def.OnGetSuccess += GetDEFHandler;
            //def.GetValue ();
            q.AddQueueGet(def);
            Firebase mag = cl.Child(cName).Child("baseStats").Child("magic");

            mag.OnGetSuccess += GetMAGHandler;
            mag.GetValue();
            q.AddQueueGet(mag);
            DoDebug("fguATK: " + attack + "\n" + "MAG: " + magic + "\n" + "DEF: " + defense);
        }
Exemplo n.º 9
0
    IEnumerator Tests()
    {
        // README
        DebugLog("This plugin simply wraps Firebase's RealTime Database REST API.\nPlease read here for better understanding of the API: https://firebase.google.com/docs/reference/rest/database/\n");

        // 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
        SimpleFirebaseUnity.Firebase firebase = SimpleFirebaseUnity.Firebase.CreateNew("https://simple-firebase-unity.firebaseio.com", "WQV9t78OywD8Pp7jvGuAi8K6g0MV8p9FAzkJ7rWK");

        // 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.
        SimpleFirebaseUnity.Firebase temporary  = firebase.Child("temporary", true);
        SimpleFirebaseUnity.Firebase lastUpdate = firebase.Child("lastUpdate");

        lastUpdate.OnGetSuccess += GetTimeStamp;

        // Make observer on "last update" time stamp
        FirebaseObserver observer = new FirebaseObserver(lastUpdate, 1f);

        observer.OnChange += (SimpleFirebaseUnity.Firebase sender, DataSnapshot snapshot) =>
        {
            DebugLog("[OBSERVER] Last updated changed to: " + snapshot.Value <long>());
        };
        observer.Start();
        DebugLog("[OBSERVER] FirebaseObserver on " + lastUpdate.FullKey + " started!");

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

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

        // Create a FirebaseQueue
        FirebaseQueue firebaseQueue = new FirebaseQueue(true, 3, 1f); // if _skipOnRequestError is set to false, queue will stuck on request Get.LimitToLast(-1).


        // Test #1: Test all firebase commands, using FirebaseQueueManager
        // The requests should be running in order
        firebaseQueue.AddQueueSet(firebase, GetSampleScoreBoard(), FirebaseParam.Empty.PrintSilent());
        firebaseQueue.AddQueuePush(firebase.Child("broadcasts", true), "{ \"name\": \"simple-firebase-csharp\", \"message\": \"awesome!\"}", true);
        firebaseQueue.AddQueueSetTimeStamp(firebase, "lastUpdate");
        firebaseQueue.AddQueueGet(firebase, "print=pretty");
        firebaseQueue.AddQueueUpdate(firebase.Child("layout", true), "{\"x\": 5.8, \"y\":-94}");
        firebaseQueue.AddQueueGet(firebase.Child("layout", true));
        firebaseQueue.AddQueueGet(lastUpdate);

        //Deliberately make an error for an example
        DebugWarning("[WARNING] There is one invalid request below (Get with invalid OrderBy) which will gives error, only for the sake of example on error handling.");
        firebaseQueue.AddQueueGet(firebase, FirebaseParam.Empty.LimitToLast(-1));

        // (~~ -.-)~~
        DebugLog("==== Wait for seconds 15f ======");
        yield return(new WaitForSeconds(15f));

        DebugLog("==== Wait over... ====");


        // Test #2: Calls without using FirebaseQueueManager
        // The requests could overtake each other (ran asynchronously)
        firebase.Child("broadcasts", true).Push("{ \"name\": \"dikra\", \"message\": \"hope it runs well...\"}", false);
        firebase.GetValue(FirebaseParam.Empty.OrderByKey().LimitToFirst(2));
        temporary.GetValue();
        firebase.GetValue(FirebaseParam.Empty.OrderByKey().LimitToLast(2));
        temporary.GetValue();

        // Please note that orderBy "rating" is possible because I already defined the index on the Rule.
        // If you use your own endpoint, you might get an error if you haven't set it on your Rule.
        firebase.Child("scores", true).GetValue(FirebaseParam.Empty.OrderByChild("rating").LimitToFirst(2));
        firebase.GetRules(GetRulesOKHandler, GetRulesFailHandler);

        // ~~(-.- ~~)
        yield return(null);

        DebugLog("==== Wait for seconds 15f ======");
        yield return(new WaitForSeconds(15f));

        DebugLog("==== Wait over... ====");

        // We need to clear the queue as the queue is left with one error command (the one we deliberately inserted last time).
        // When the queue stuck with an error command at its head, the next (or the newly added command) will never be processed.
        firebaseQueue.ForceClearQueue();
        yield return(null);

        // Test #3: Delete the frb_child and broadcasts
        firebaseQueue.AddQueueGet(firebase);
        firebaseQueue.AddQueueDelete(temporary);

        // Please notice that the OnSuccess/OnFailed handler is not inherited since Child second parameter not set to true.
        DebugLog("'broadcasts' node is deleted silently.");
        firebaseQueue.AddQueueDelete(firebase.Child("broadcasts"));
        firebaseQueue.AddQueueGet(firebase);

        // ~~(-.-)~~
        yield return(null);

        DebugLog("==== Wait for seconds 15f ======");
        yield return(new WaitForSeconds(15f));

        DebugLog("==== Wait over... ====");
        observer.Stop();
        DebugLog("[OBSERVER] FirebaseObserver on " + lastUpdate.FullKey + " stopped!");
    }
Exemplo n.º 10
0
    IEnumerator Tests()
    {
        // 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(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.
        //	Firebase temporary = firebase.Child (ShowNetworkInterfaces(), true);
        //	Firebase lastUpdate = firebase.Child ("lastUpdate");
        //
        //	lastUpdate.OnGetSuccess += GetTimeStamp;
        //
        //	// Make observer on "last update" time stamp
        FirebaseObserver observer = new FirebaseObserver(firebase, 1f);

        observer.OnChange += (Firebase sender, DataSnapshot snapshot) => {
            DoDebug("[OBSERVER] Last updated changed to: " + snapshot.Value <long>());
            firebase.Child("action", true).GetValue();
        };
        observer.Start();
        //	DoDebug ("[OBSERVER] FirebaseObserver on " + lastUpdate.FullKey +" started!");
        //
        //	// Print details
        DoDebug("Firebase endpoint: " + firebase.Endpoint);
        //	DoDebug("Firebase key: " + firebase.Key);
        //	DoDebug("Firebase fullKey: " + firebase.FullKey);
        //	DoDebug("Firebase child key: " + temporary.Key);
        //	DoDebug("Firebase child fullKey: " + temporary.FullKey);

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

        //firebase.UpdateValue(firebase.Child("action",true),"{\"sync\":DDD}");
        // Create a FirebaseQueue
        FirebaseQueue firebaseQueue = new FirebaseQueue();

        // Test #1: Test all firebase commands, using FirebaseQueueManager
        // The requests should be running in order
        //firebaseQueue.AddQueueSet (firebase, GetSampleScoreBoard (), FirebaseParam.Empty.PrintSilent ());
        //firebaseQueue.AddQueuePush (firebase.Child ("broadcasts", true), "{ \"name\": \"simple-firebase-csharp\", \"message\": \"awesome!\"}", true);
        //firebaseQueue.AddQueueSetTimeStamp (firebase, "lastUpdate");
        //firebaseQueue.AddQueueGet (firebase, "print=pretty");
        firebaseQueue.AddQueueUpdate(firebase.Child("action", true), "{\"sync\": \"DOne\"}", true);


        //   firebaseQueue.AddQueueGet(firebase.Child("action", true));
        //firebaseQueue.AddQueueGet (lastUpdate);
        //
        ////Deliberately make an error for an example
        //DoDebug("[WARNING] There is one invalid request below which will gives error, only for example on error handling.");
        //firebaseQueue.AddQueueGet (firebase, FirebaseParam.Empty.LimitToLast(-1));
        //
        //
        //// (~~ -.-)~~
        DoDebug("==== Wait for seconds 15f ======");
        yield return(new WaitForSeconds(15f));

        DoDebug("==== Wait over... ====");


        // Test #2: Calls without using FirebaseQueueManager
        // The requests could overtake each other (ran asynchronously)
        //	firebase.Child("broadcasts", true).Push("{ \"name\": \"dikra\", \"message\": \"hope it runs well...\"}", true);
        //	firebase.GetValue(FirebaseParam.Empty.OrderByKey().LimitToFirst(2));
        //	temporary.GetValue ();
        //	firebase.GetValue (FirebaseParam.Empty.OrderByKey().LimitToLast(2));
        //	temporary.GetValue ();
        //	firebase.Child ("scores", true).GetValue(FirebaseParam.Empty.OrderByChild ("rating").LimitToFirst(2));
        //	firebase.GetRules (GetRulesOKHandler, GetRulesFailHandler);

        // ~~(-.- ~~)
        yield return(null);

        DoDebug("==== Wait for seconds 15f ======");
        yield return(new WaitForSeconds(15f));

        DoDebug("==== Wait over... ====");


        // Test #3: Delete the frb_child and broadcasts
        //	firebaseQueue.AddQueueGet (firebase);
        //	firebaseQueue.AddQueueDelete(temporary);
        // please notice that the OnSuccess/OnFailed handler is not inherited since Child second parameter not set to true.
        DoDebug("'broadcasts' node is deleted silently.");
        //	firebaseQueue.AddQueueDelete (firebase.Child ("broadcasts"));
        //	firebaseQueue.AddQueueGet (firebase);

        // ~~(-.-)~~
        yield return(null);

        DoDebug("==== Wait for seconds 15f ======");
        yield return(new WaitForSeconds(15f));

        DoDebug("==== Wait over... ====");
        //	observer.Stop ();
        //	DoDebug ("[OBSERVER] FirebaseObserver on " + lastUpdate.FullKey +" stopped!");
    }
Exemplo n.º 11
0
 private void Awake()
 {
     instance              = this;
     firebase.OnGetFailed += GetFailHandler;
     firebaseQueue         = new FirebaseQueue(true, 3, 1f);
 }
Exemplo n.º 12
0
        private void addIVals()
        {
            FirebaseQueue q  = new FirebaseQueue();
            Firebase      fb = Firebase.CreateNew("coop-rpg.firebaseio.com/ItemLU", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");

            Firebase weap = fb.Child("weapons").Child(weapon).Child("value");

            if (wType.Equals("attack"))
            {
                weap.OnGetSuccess += GetATKHandler;
                //wNum.GetValue ();
            }
            if (wType.Equals("magic"))
            {
                weap.OnGetSuccess += GetMAGHandler;
                //wNum.GetValue ();
            }

            q.AddQueueGet(weap);

            Firebase a1 = fb.Child("accesory").Child(acc1).Child("value");
            Firebase a2 = fb.Child("accesory").Child(acc2).Child("value");

            if (acc1Type.Equals("attack"))
            {
                a1.OnGetSuccess += GetATKHandler;
                //acc1Val.GetValue ();
            }

            if (acc1Type.Equals("magic"))
            {
                a1.OnGetSuccess += GetMAGHandler;
                //acc1Val.GetValue ();
            }

            if (acc1Type.Equals("defense"))
            {
                a1.OnGetSuccess += GetDEFHandler;
                //acc1Val.GetValue ();
            }
            q.AddQueueGet(a1);

            if (acc2Type.Equals("attack"))
            {
                a2.OnGetSuccess += GetATKHandler;
                //acc2Val.GetValue ();
            }

            if (acc2Type.Equals("magic"))
            {
                a2.OnGetSuccess += GetMAGHandler;
                //acc2Val.GetValue ();
            }

            if (acc2Type.Equals("defense"))
            {
                a2.OnGetSuccess += GetDEFHandler;
                //acc2Val.GetValue ();
            }

            q.AddQueueGet(a2);
        }
Exemplo n.º 13
0
        private void getVals()
        {
            FirebaseQueue q  = new FirebaseQueue();
            Firebase      fb = Firebase.CreateNew("coop-rpg.firebaseio.com/Characters", "nofP6v645gh35aA1jlQGOc4ueceuDZqEIXu7qMs1");
            Firebase      chara;

            chara = fb.Child("Example");
            Firebase expFB;

            expFB = chara.Child("EXP");
            expFB.OnGetSuccess += GetEXPHandler;
            expFB.OnGetFailed  += GetEXPHandlerBAD;
            //expFB.GetValue ();
            q.AddQueueGet(expFB);

            Firebase atkFB;

            atkFB = chara.Child("stats").Child("attack");
            atkFB.OnGetSuccess += GetATKHandler;
            atkFB.OnGetFailed  += GetATKHandlerBAD;
            //atkFB.GetValue ();
            q.AddQueueGet(atkFB);

            Firebase magFB;

            magFB = chara.Child("stats").Child("magic");
            magFB.OnGetSuccess += GetMAGHandler;

            //magFB.GetValue ();
            q.AddQueueGet(magFB);

            Firebase defFB;

            defFB = chara.Child("stats").Child("defense");
            defFB.OnGetSuccess += GetDEFHandler;
            //defFB.GetValue ();
            q.AddQueueGet(defFB);

            Firebase hpFB;

            hpFB = chara.Child("HP");
            hpFB.OnGetSuccess += GetHPHandler;
            hpFB.OnGetFailed  += GetHPHandlerBAD;
            //hpFB.GetValue ("print=pretty");
            q.AddQueueGet(hpFB);

            Firebase classFB;

            classFB = chara.Child("class");
            classFB.OnGetSuccess += GetClassName;

            //classFB.GetValue ("print=pretty");
            q.AddQueueGet(classFB);

            Firebase itemFB = chara.Child("equipment");
            Firebase acc1FB = itemFB.Child("acc1");

            acc1FB.OnGetSuccess += GetAcc1Name;
            //acc1FB.GetValue ();
            q.AddQueueGet(acc1FB);
            Firebase acc2FB = itemFB.Child("acc2");

            acc2FB.OnGetSuccess += GetAcc2Name;
            //acc2FB.GetValue ();
            q.AddQueueGet(acc2FB);
            Firebase weapFB = itemFB.Child("weapon");

            weapFB.OnGetSuccess += GetWeapName;
            //weapFB.GetValue ();
            q.AddQueueGet(weapFB);
            Firebase arFB = itemFB.Child("armor");

            arFB.OnGetSuccess += GetArmorName;
            //arFB.GetValue ();
            q.AddQueueGet(arFB);
        }