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)); })); }
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)); })); }
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(); }
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); } }); }
// 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; }
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; }
public void SetResponseGreen() { bool result = Uniredis.ParseSetResponse("+OK"); Assert.AreEqual(result, true); }
public void SetRandomResponseGreen() { bool result = Uniredis.ParseSetResponse("df98273rhsdas"); Assert.AreEqual(result, false); }
public void SetRandomResponseRed() { bool result = Uniredis.ParseSetResponse("df98273rhsdas"); Assert.AreNotEqual(result, true); }
public void SetEmptyResponseRed() { bool result = Uniredis.ParseSetResponse(""); Assert.AreNotEqual(result, true); }
public void SetResponseRed() { bool result = Uniredis.ParseSetResponse("+OK"); Assert.AreNotEqual(result, false); }
public void SetEmptyResponseGreen() { bool result = Uniredis.ParseSetResponse(""); Assert.AreEqual(result, false); }
public void SetErrorResponseRed() { bool result = Uniredis.ParseSetResponse("-ERR test"); Assert.AreNotEqual(result, true); }
public void GetErrorResponseGreen() { string result = Uniredis.ParseGetResponse("$-1"); Assert.AreEqual(result, null); }
public void GetRandomResponseRed() { string result = Uniredis.ParseGetResponse("asjdnq38jnasda2"); Assert.AreNotEqual(result, "ciao"); }
public void GetRandomResponseGreen() { string result = Uniredis.ParseGetResponse("asjdnq38jnasda2"); Assert.AreEqual(result, null); }
public void GetErrorResponseRed() { string result = Uniredis.ParseGetResponse("$-1"); Assert.AreNotEqual(result, "ciao"); }
public void GetResponseGreen() { string result = Uniredis.ParseGetResponse("$4\r\nciao\r\n"); Assert.AreEqual(result, "ciao"); }
public void SetErrorResponseGreen() { bool result = Uniredis.ParseSetResponse("-ERR test"); Assert.AreEqual(result, false); }