public void ScreenShot() { TargetCamera.targetTexture = renderTexture; TargetCamera.Render(); RenderTexture.active = renderTexture; texture.ReadPixels(rect, 0, 0); texture.Apply(); TargetCamera.targetTexture = null; RenderTexture.active = null; // 3 channels : RGB | Total size: 3 * width * height byte[] data = texture.GetRawTextureData(); // char[] encoded = Encoding.UTF8.GetChars(data); // string encodedDefault = Encoding.Default.GetString(data); string encodedASCII = Encoding.ASCII.GetString(data); // byte[] decoded = Encoding.UTF8.GetBytes(encoded); // Debug.LogFormat("{0}x{1}x{2} - ASCII {3} - UTF8 {4}", screenWidth, screenHeight, 3, encodedASCII.Length, encodedDefault.Length ); // Debug.LogFormat("{0} vs {1} - {2}", data.Length, encoded.Length, decoded.Length); redis.SendCommand(RedisCommand.SET, Key, /* new string(encoded) */ encodedASCII); redis.SendCommand(RedisCommand.SET, Key + ":width", screenWidth.ToString()); redis.SendCommand(RedisCommand.SET, Key + ":height", screenHeight.ToString()); redis.SendCommand(RedisCommand.SET, Key + ":channels", "3"); }
void f_key_ids_selected(string id) { lblKeySelected_Time.Text = ""; lblKeyID_Selected.Text = ""; txtEditor.Text = ""; if (id != null && m_key_ids.Length > 0 && m_key_selected != null) { //string id = m_key_ids[index]; lblKeySelected_Time.Text = id; lblKeyID_Selected.Text = id; string data = ""; try { data = m_redis.ReadString(m_redis.SendCommand(RedisCommand.HGET, m_key_selected.key_full, id)); var o = JsonConvert.DeserializeObject(data); string json = JsonConvert.SerializeObject(o, Formatting.Indented); txtEditor.Text = json; } catch (Exception e) { txtEditor.Text = data; } } }
public static Texture2D GetImageAsTexture(RedisDataAccessProvider redis, string key) { int commandId = redis.SendCommand(RedisCommand.GET, key + ":width"); int?width = Utils.RedisTryReadInt(redis, commandId); commandId = redis.SendCommand(RedisCommand.GET, key + ":height"); int?height = Utils.RedisTryReadInt(redis, commandId); commandId = redis.SendCommand(RedisCommand.GET, key + ":channels"); int?channels = Utils.RedisTryReadInt(redis, commandId); if (width == null || height == null || channels == null) { return(null); } Texture2D texture = new Texture2D((int)width, (int)height, TextureFormat.RGB24, false, false); byte[] imageData = new byte[(int)width * (int)height * (int)channels]; bool succeed = GetImageIntoPreallocatedTexture(redis, key, ref texture, imageData, (int)width, (int)height, (int)channels); if (succeed) { return(texture); } else { return(null); } }
public async Task Set(string key, string value) { await Task.Run(() => { client.SendCommand(RedisCommand.SET, key, value); client.WaitComplete(); }); }
public static Position RedisTryGetPosition(RedisDataAccessProvider redis, string key) { int commandId = redis.SendCommand(RedisCommand.GET, key); string positionData = Utils.RedisTryReadString(redis, commandId); return(JSONTo <Position>(positionData)); }
public oKey(RedisDataAccessProvider redis, string s) { string[] a = s.Split(new char[] { '#', '.' }); this.key_full = s; this.key0 = a[0]; this.level = 0; if (a.Length > 1) { this.key1 = a[1]; this.level = 1; } if (a.Length > 2) { this.key2 = a[2]; this.level = 2; } if (a.Length > 3) { this.key3 = a[3]; this.level = 3; } try { string[] ks = redis.ReadMultiString(redis.SendCommand(RedisCommand.HKEYS, s)); this.keys_last = ks.OrderBy(x => x).ToArray(); } catch (Exception e) { } }
public static ExtrinsicsParameters RedisTryGetExtrinsics(RedisDataAccessProvider redis, string key) { int commandId = redis.SendCommand(RedisCommand.GET, key); string extrinsicsData = null; extrinsicsData = Utils.RedisTryReadString(redis, commandId); return(JSONTo <ExtrinsicsParameters>(extrinsicsData)); }
public void ExistsAfter_DEL_SREM_Bug_SIMULATION1() { _redis.Configuration.LogUnbalancedCommands = true; _redis.WaitComplete(_redis.SendCommand(RedisCommand.FLUSHALL)); _redis.Key.Exists("TEST"); Dictionary <string, string> _values = new Dictionary <string, string>(); _values.Add("v1", "testvalue1"); _values.Add("v2", "testvalue2"); _values.Add("v3", "testvalue3"); _values.Add("v4", "testvalue4"); _redis.Hash["TEST"].Set(_values); _redis.Key.Exists("TEST"); }
/// <summary> /// Tries to get 3D pose information saved in redis /// </summary> /// <param name="key">the key whereto look for 3d pose"</param> /// <returns></returns> public static Matrix4x4?RedisTryGetPose3D(RedisDataAccessProvider redis, string key) { int commandId = redis.SendCommand(RedisCommand.GET, key); string jsonPose = Utils.RedisTryReadString(redis, commandId); if (jsonPose != null) { // Hand made parsing return(JSONToPose3D(jsonPose)); } return(null); }
private ImageData load() { int commandId = redis.SendCommand(RedisCommand.GET, Key + ":width"); int?width = Utils.RedisTryReadInt(redis, commandId); commandId = redis.SendCommand(RedisCommand.GET, Key + ":height"); int?height = Utils.RedisTryReadInt(redis, commandId); commandId = redis.SendCommand(RedisCommand.GET, Key + ":channels"); int?channels = Utils.RedisTryReadInt(redis, commandId); commandId = redis.SendCommand(RedisCommand.GET, Key + ":pixelformat"); string pixelformat = Utils.RedisTryReadString(redis, commandId); if (width == null || height == null || channels == null) { return(new ImageData()); } return(new ImageData((int)width, (int)height, (int)channels, pixelformat)); }
public static bool GetImageIntoPreallocatedTexture(RedisDataAccessProvider redis, string key, ref Texture2D texture, byte[] textureRaw, int width, int height, int channels) { int commandId = redis.SendCommand(RedisCommand.GET, key); // 70-90% of the time is spent here textureRaw = Utils.RedisTryReadData(redis, commandId); if (textureRaw == null) { return(false); } if (channels == 2) { textureRaw = Utils.GRAY16ToRGB24((int)width, (int)height, textureRaw); } texture.LoadRawTextureData(textureRaw); texture.Apply(); return(true); }
public bool Add(string value) { return(_provider.ReadInt(_provider.SendCommand(RedisCommand.SADD, _name, value)) == 1); }
public bool Remove(params string[] keys) { return(_provider.ReadInt(_provider.SendCommand(RedisCommand.DEL, keys)) == 1); }
public void Clear() { _provider.WaitComplete(_provider.SendCommand(RedisCommand.DEL, _name)); }
/// <summary> /// Executes a Redis command, when requested. /// </summary> /// <param name="redisDap">DAO that will communicate with the cache.</param> /// <param name="log">Logger to output information about what's occurring.</param> /// <param name="cmdToExecute">The command we're executing.</param> /// <param name="paramArgs">The parameters to send with the command.</param> public static void ExecuteRedisCommand(this RedisDataAccessProvider redisDap, ILogger log, RedisCommand cmdToExecute, params string[] paramArgs) { log.LogRedisMessage(cmdToExecute, paramArgs); redisDap.SendCommand(cmdToExecute, paramArgs); }
void f_load(bool cache_selected = false) { f_message(); treeKeys.Nodes.Clear(); listKeys.Items.Clear(); lblKeyID_Selected.Text = ""; lblKeyID_Counter.Text = ""; string key_full_selected = ""; if (cache_selected && m_key_selected != null) { key_full_selected = m_key_selected.key_full; } try { m_redis = new RedisDataAccessProvider(); m_redis.Configuration = new Configuration() { Host = txtIP.Text.Trim(), Port = Convert.ToInt16(txtPort.Text.Trim()) }; m_redis.Connect(); string[] keys = m_redis.ReadMultiString(m_redis.SendCommand(RedisCommand.KEYS, "*")); m_keys = keys.Select(x => new oKey(m_redis, x)).ToArray(); var keys_0 = keys.Select(x => x.Split(new char[] { '#', '.' })) .Select(x => x[0]).Distinct().OrderBy(x => x).ToArray(); TreeNode[] nodes_0 = new TreeNode[keys_0.Length]; for (var i = 0; i < keys_0.Length; i++) { string key_0 = keys_0[i]; nodes_0[i] = new TreeNode(key_0); var okeys_1 = m_keys.Where(x => x.key_full.StartsWith(key_0 + "#") || x.key_full.StartsWith(key_0 + ".")).OrderBy(x => x.key_full).ToArray(); string[] keys_1 = okeys_1.Select(x => x.key_full.Split(new char[] { '#', '.' })[1]).Distinct().OrderBy(x => x).ToArray(); if (keys_1.Length == 0) { nodes_0[i].Tag = new oKey() { key0 = key_0, level = 0 }; } else { for (var i1 = 0; i1 < keys_1.Length; i1++) { string key_1 = keys_1[i1]; var nodes_1 = new TreeNode(key_1); nodes_0[i].Nodes.Add(nodes_1); var okeys_2 = m_keys.Where(x => (x.key_full.StartsWith(key_0 + "#") || x.key_full.StartsWith(key_0 + ".")) && (x.key_full.Contains(key_1 + "#") || x.key_full.Contains(key_1 + "."))).OrderBy(x => x.key_full).ToArray(); string[] keys_2 = okeys_2.Select(x => x.key_full.Split(new char[] { '#', '.' })[2]).Distinct().OrderBy(x => x).ToArray(); if (keys_2.Length == 0) { nodes_1.Tag = new oKey() { key0 = key_0, key1 = key_1, level = 1 }; } else { for (var i2 = 0; i2 < keys_2.Length; i2++) { string key_2 = keys_2[i2]; var nodes_2 = new TreeNode(key_2) { Tag = new oKey() { key0 = key_0, key1 = key_1, key2 = key_2, level = 2 } }; nodes_1.Nodes.Add(nodes_2); } } } } } treeKeys.Nodes.AddRange(nodes_0); //f_message("OK"); //Thread.Sleep(100); treeKeys.ExpandAll(); //Thread.Sleep(100); if (key_full_selected.Length > 0) { CallRecursive(key_full_selected); } } catch (Exception err) { f_message("FAIL: " + err.Message); } }
public string Get() { return(_provider.ReadString(_provider.SendCommand(RedisCommand.GET, _name))); }
public void Begin() { _provider.WaitComplete(_provider.SendCommand(RedisCommand.MULTI)); }
public int Publish(string channel, string message) { return _provider.ReadInt(_provider.SendCommand(RedisCommand.PUBLISH, channel, message)); }
public bool Add(string score, string member) { return(_provider.ReadInt(_provider.SendCommand(RedisCommand.ZADD, _name, score, member)) == 1); }
public void Append(string value) { _provider.ReadInt(_provider.SendCommand(RedisCommand.RPUSH, _name, value)); }