Beispiel #1
0
    public BigInteger GetRecentKeycode(DataSnapshot snapshot2)
    {
        Printlog(nameof(GetRecentKeycode));
        BigInteger startKeyCode;

        reference = FirebaseDatabase.DefaultInstance.GetReference("UID");

        lock (reference.GetValueAsync().ContinueWith(task =>
        {
            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;

                foreach (DataSnapshot uidkeycode in snapshot.Children)
                {
                    UidKey dataDictionary = (UidKey)uidkeycode.Value;
                    startKeyCode = BigInteger.Parse(dataDictionary.uidKey);
                    Debug.Log("Keycode Setting Finish\nKeycode : " + startKeyCode);
                }
            }
            else
            {
                Debug.Log("Get Value ERROR");
            }
        }))
        {
        }
        return(startKeyCode);
    }
Beispiel #2
0
    public void InputData(User rank, BigInteger setKeyCode)
    {
        reference = FirebaseDatabase.DefaultInstance.RootReference;
        Printlog(nameof(InputData));
        UidKey updateKey     = new UidKey(setKeyCode.ToString());
        string updateKeyJson = JsonUtility.ToJson(updateKey);
        string json          = JsonUtility.ToJson(rank);

        // 데이터를 json형태로 반환

        reference.Child("rank").Child(setKeyCode.ToString()).SetRawJsonValueAsync(json);
        reference.Child("UID").SetRawJsonValueAsync(updateKeyJson);
        // 생성된 키의 자식으로 json데이터를 삽입

        PrintData();
    }
Beispiel #3
0
        public bool Create(object keyData, out IKey key, out string errorMessage)
        {
            key          = null;
            errorMessage = string.Empty;
            switch (keyData)
            {
            case long longKeyData:
                key = new UidKey(longKeyData);
                return(true);

            case UidGenerator uidGenerator:
                key = new UidKey(uidGenerator.GenerateUid());
                return(true);
            }
            errorMessage = "keyData type is not supported.";
            return(false);
        }
Beispiel #4
0
    public BigInteger InitKeyCode()
    {
        Printlog(nameof(InitKeyCode));
        BigInteger startKeyCode = 0;

        reference = FirebaseDatabase.DefaultInstance.GetReference("UID");
        UidKey defaultkey     = new UidKey("99999999");
        string defaultkeyjson = JsonUtility.ToJson(defaultkey);

        lock (reference.GetValueAsync().ContinueWith(task =>
        {
            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;

                if (snapshot.HasChildren == true)
                {
                    Debug.Log("Defualt DB is Exists");
                    InputData(
                        MakeUserData(), UpdateKeyCode(GetRecentKeycode(snapshot))
                        );
                }
                else
                {
                    Debug.Log("Defualt DB is Not Exists");
                    startKeyCode = BigInteger.Parse("99999999");
                    reference.SetRawJsonValueAsync(defaultkeyjson);
                    InputData(MakeUserData(), UpdateKeyCode(startKeyCode));
                }
            }
            else
            {
                Debug.Log("Get Value ERROR");
            }
        }))

            return(startKeyCode);
    }
Beispiel #5
0
 protected bool Equals(UidKey other)
 {
     return(Uid == other.Uid);
 }