Пример #1
0
    private void Start()
    {
        Firebase firebase = Firebase.CreateNew(dbname);
        Firebase mydb     = firebase.Child(dbroot);

        //Like init
        mydb.OnGetSuccess += OnChangeDB;
        mydb.GetValue();
        //Conect observer
        dbObserver           = new FirebaseObserver(mydb, 1f);
        dbObserver.OnChange += this.OnChangeDB;
        dbObserver.Start();
    }
Пример #2
0
    // Initialize the Firebase database:
    void InitializeFirebase()
    {
        firebase = SimpleFirebaseUnity.Firebase.CreateNew(databaseUrl);
        peopleDB = firebase.Child(DBPath);

        // 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;

        peopleDB.OnGetSuccess += OnChangeDB;
        peopleDB.GetValue();

        // Make observer on "last update" time stamp
        dbObserver           = new FirebaseObserver(peopleDB, 1f);
        dbObserver.OnChange += this.OnChangeDB;
        dbObserver.Start();

        //DoDebug("[OBSERVER] FirebaseObserver on " + lastUpdate.FullKey + " started!");

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