예제 #1
0
    public static void Get(MonoBehaviour launcher, string key, Action <string, string> callback)
    {
        String query = String.Format("GET {0}", key);

        launcher.StartCoroutine(Uniredis.Query(query, (result) =>
        {
            callback(null, ParseGetResponse(result));
        }));
    }
예제 #2
0
    public static void Set(MonoBehaviour launcher, string key, object value, Action <string, bool> callback)
    {
        String query = String.Format("SET {0} {1}", key, value);

        launcher.StartCoroutine(Uniredis.Query(query, (result) =>
        {
            callback(null, ParseSetResponse(result));
        }));
    }
예제 #3
0
    public IEnumerator LoadRestartGame()
    {
        Uniredis.Set(this, SystemInfo.deviceUniqueIdentifier + "LastScore", coins, (error, result) =>
        {
            if (error == null)
            {
                Debug.Log("SET LASTSCORE SUCCESS");
            }
        });
        Uniredis.Get(this, SystemInfo.deviceUniqueIdentifier + "HighScore", (error, result) =>
        {
            if (error == null)
            {
                if (int.Parse(result) < coins)
                {
                    Uniredis.Set(this, SystemInfo.deviceUniqueIdentifier + "HighScore", coins, (error1, result1) =>
                    {
                        if (error == null)
                        {
                            Debug.Log("SET HIGHSCORE SUCCESS");
                        }
                    });
                }
            }
        });
        Uniredis.Get(this, "WorldRecord", (error, result) =>
        {
            if (error == null)
            {
                if (int.Parse(result) < coins)
                {
                    Uniredis.Set(this, "WorldRecord", coins, (error1, result1) =>
                    {
                        if (error == null)
                        {
                            Debug.Log("SET WORLDRECORD SUCCESS");
                        }
                    });
                }
            }
        });
        yield return(new WaitForSeconds(restartTimer));

        RestartGame();
    }
예제 #4
0
    void Start()
    {
        Uniredis.Set(this, "Hello", "World", (error, result) =>
        {
            if (error == null)
            {
                Debug.Log(result);
            }
        });

        Uniredis.Get(this, "Hello", (error, result) =>
        {
            if (error == null)
            {
                Debug.Log(result);
            }
        });
    }
예제 #5
0
    // Start is called before the first frame update
    void Start()
    {
        Uniredis.Get(this, "WorldRecord", (error, result) =>
        {
            if (error == null)
            {
                worldRecord.text = "World Record: " + result;
            }
        });

        Uniredis.Get(this, SystemInfo.deviceUniqueIdentifier + "HighScore", (error, result) =>
        {
            if (error == null)
            {
                highScore.text = "Your HighScore: " + result;
            }
        });

        Uniredis.Get(this, SystemInfo.deviceUniqueIdentifier + "LastScore", (error, result) =>
        {
            if (error == null)
            {
                lastScore.text = "Your LastScore: " + result;
            }
        });

        gamePlayer    = FindObjectOfType <PlayerController>();
        coinText.text = "Coins: " + coins;
        StartCoroutine("CoinWave");
        StartCoroutine("WeightWave");
        timerDashCooldown                = gamePlayer.cooldownDash;
        timerDashDuration                = gamePlayer.durationDash;
        timerBunshinCooldown             = gamePlayer.cooldownBunshin;
        timerBunshinDuration             = gamePlayer.durationBunshin;
        timerDashCooldownText.text       = "" + timerDashCooldown;
        timerDashCooldownText.enabled    = false;
        timerBunshinCooldownText.text    = "" + timerBunshinCooldown;
        timerBunshinCooldownText.enabled = false;
        imageDashSprite    = rectTransformDashSprite.GetComponent <Image>();
        imageBunshinSprite = rectTransformBunshinSprite.GetComponent <Image>();
        imageJumpSprite    = rectTransformJumpSprite.GetComponent <Image>();
        isJumpAvailable    = true;
    }
예제 #6
0
    public void Connect()
    {
        if (socket != null)
        {
            throw new Exception("You are already connected");
        }

        Uniredis Uniredis = Resources.Load <Uniredis>("Uniredis");

        socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        socket.Connect(Uniredis.Host, Uniredis.Port);

        if (!socket.Connected)
        {
            socket.Close();
            socket = null;
        }

        socket.Blocking = false;
    }
예제 #7
0
    public void SetResponseGreen()
    {
        bool result = Uniredis.ParseSetResponse("+OK");

        Assert.AreEqual(result, true);
    }
예제 #8
0
    public void SetRandomResponseGreen()
    {
        bool result = Uniredis.ParseSetResponse("df98273rhsdas");

        Assert.AreEqual(result, false);
    }
예제 #9
0
    public void SetRandomResponseRed()
    {
        bool result = Uniredis.ParseSetResponse("df98273rhsdas");

        Assert.AreNotEqual(result, true);
    }
예제 #10
0
    public void SetEmptyResponseRed()
    {
        bool result = Uniredis.ParseSetResponse("");

        Assert.AreNotEqual(result, true);
    }
예제 #11
0
    public void SetResponseRed()
    {
        bool result = Uniredis.ParseSetResponse("+OK");

        Assert.AreNotEqual(result, false);
    }
예제 #12
0
    public void SetEmptyResponseGreen()
    {
        bool result = Uniredis.ParseSetResponse("");

        Assert.AreEqual(result, false);
    }
예제 #13
0
    public void SetErrorResponseRed()
    {
        bool result = Uniredis.ParseSetResponse("-ERR test");

        Assert.AreNotEqual(result, true);
    }
예제 #14
0
    public void GetErrorResponseGreen()
    {
        string result = Uniredis.ParseGetResponse("$-1");

        Assert.AreEqual(result, null);
    }
예제 #15
0
    public void GetRandomResponseRed()
    {
        string result = Uniredis.ParseGetResponse("asjdnq38jnasda2");

        Assert.AreNotEqual(result, "ciao");
    }
예제 #16
0
    public void GetRandomResponseGreen()
    {
        string result = Uniredis.ParseGetResponse("asjdnq38jnasda2");

        Assert.AreEqual(result, null);
    }
예제 #17
0
    public void GetErrorResponseRed()
    {
        string result = Uniredis.ParseGetResponse("$-1");

        Assert.AreNotEqual(result, "ciao");
    }
예제 #18
0
    public void GetResponseGreen()
    {
        string result = Uniredis.ParseGetResponse("$4\r\nciao\r\n");

        Assert.AreEqual(result, "ciao");
    }
예제 #19
0
    public void SetErrorResponseGreen()
    {
        bool result = Uniredis.ParseSetResponse("-ERR test");

        Assert.AreEqual(result, false);
    }