Esempio n. 1
0
    private void OnNewDoorTime(object sender, ValueChangedEventArgs args)
    {
        Debug.Log("New door time REMOVE");
        string json = args.Snapshot.GetRawJsonValue();

        if (string.IsNullOrEmpty(json))

        {
            doorTime = new DoorTime(null, null, false);
        }
        else
        {
            doorTime = JsonConvert.DeserializeObject <DoorTime>(json);
        }


        if (doorTime.HasExpired())
        {
            Debug.Log("Door has expired");
            DeleteRequest();
        }

        if (doorTime.unlocked)
        {
            Unlock();
        }
    }
Esempio n. 2
0
    //Delete Request
    void DeleteRequest()
    {
        doorTime = new DoorTime(null, null, false);
        SendDoorTime(doorTime);

        // ItemManager.instance.RemoveDoorItem();
    }
Esempio n. 3
0
    void SendDoorTime(DoorTime doorTime)
    {
        string json = JsonConvert.SerializeObject(doorTime);

        FirebaseCommunicator.instance.SendObject(json, referenceName, (task) =>
        {
            if (task.IsFaulted)
            {
                Debug.LogError("Failed to send door request");
                return;
            }
            else if (task.IsCompleted)
            {
                Debug.Log("Door request sent");
            }
        });
    }
Esempio n. 4
0
    void GetDoorTime()
    {
        FirebaseCommunicator.instance.GetObject(referenceName, (task) =>
        {
            if (task.IsFaulted)
            {
                Debug.LogError("Failed getting door time");
                return;
            }
            else if (task.IsCompleted)
            {
                string json = task.Result.GetRawJsonValue();
                if (string.IsNullOrEmpty(json))

                {
                    doorTime = new DoorTime(null, null, false);
                }
                else
                {
                    doorTime = JsonConvert.DeserializeObject <DoorTime>(json);
                }


                if (doorTime.HasExpired())
                {
                    Debug.Log("Door has expired");
                    DeleteRequest();
                }

                if (doorTime.unlocked)
                {
                    Unlock();
                }
            }
        });
    }
Esempio n. 5
0
 void CreateNewRequest()
 {
     doorTime = new DoorTime(null, DateTime.Now.ToString(dateFormat));
 }