public bool Set <T>(string key, T value) { try { NetworkStream stream = _client.GetStream(); BinaryFormatter binaryFormatter = new BinaryFormatter(); SetCacheRequest cacheEntry; using (MemoryStream ms = new MemoryStream()) { binaryFormatter.Serialize(ms, value); cacheEntry = new SetCacheRequest(_appId, key, ms.ToArray(), 300); } using (MemoryStream cacheEntryMs = new MemoryStream()) { binaryFormatter.Serialize(cacheEntryMs, cacheEntry); byte[] bytes = cacheEntryMs.ToArray(); stream.Write(bytes, 0, bytes.Length); } Byte[] responseBytes = new Byte[2048]; stream.Read(responseBytes, 0, responseBytes.Length); using (MemoryStream responseMs = new MemoryStream(responseBytes)) { ICacheResponse cacheResponse = (ICacheResponse)binaryFormatter.Deserialize(responseMs); return(cacheResponse.IsSuccess); } } catch (Exception e) { Console.WriteLine("Exception: {0}", e); } return(false); }
internal void SetCache(string pluginId, string key, object value) { WebOutput cacheRequestMessage = new SetCacheRequest(pluginId, key, value); // TODO: This message needs to be added to the output message queue throw new NotImplementedException(); }