Example #1
0
        public void Close()
        {
            lock (Lock)
            {
                if (!IsOpen)
                {
                    return;
                }

                Manifest = null;

                Path   = "";
                IsOpen = false;

                try
                {
                    var stream = Client.GetStream();
                    SendMessage(stream, "{\"command\":\"close\"}");

                    var responseJson = JsonValue.Parse(ReceiveMessage(stream));
                    if (responseJson.ContainsKey("error"))
                    {
                        throw new InvalidDataException(responseJson["error"].ToString());
                    }
                }
                catch
                {
                }
            }
        }
Example #2
0
        public void FetchManifest()
        {
            lock (Lock)
            {
                if (!IsOpen)
                {
                    return;
                }

                var stream = Client.GetStream();
                SendMessage(stream, "{\"command\":\"manifest\"}");

                var response = ReceiveMessage(stream);
                var json     = JsonValue.Parse(response);
                if (json.ContainsKey("error"))
                {
                    throw new InvalidDataException("Cannot fetch database manifest.");
                }

                Manifest = new DatabaseManifest(json["manifest"]);
            }
        }