Example #1
0
        private void HandleFetch(int fetchId, JObject json)
        {
            JetFetcher fetcher = null;

            lock (this.openFetches)
            {
                if (this.openFetches.ContainsKey(fetchId))
                {
                    fetcher = this.openFetches[fetchId];
                }
            }

            if (fetcher != null)
            {
                JToken parameters = json["params"];
                if ((parameters != null) && (parameters.Type != JTokenType.Null))
                {
                    fetcher.CallFetchCallback(parameters);
                }
                else
                {
                    // Todo: Log error
                }
            }
        }
Example #2
0
 private void RegisterFetcher(int fetchId, JetFetcher fetcher)
 {
     lock (this.openFetches)
     {
         this.openFetches.Add(fetchId, fetcher);
     }
 }
Example #3
0
        public JObject Fetch(out FetchId id, Matcher matcher, Action <JToken> fetchCallback, Action <bool, JToken> responseCallback, double responseTimeoutMs)
        {
            int        fetchId = Interlocked.Increment(ref this.fetchIdCounter);
            JetFetcher fetcher = new JetFetcher(fetchCallback);

            this.RegisterFetcher(fetchId, fetcher);

            JObject parameters = new JObject();
            JObject path       = this.FillPath(matcher);

            if (path != null)
            {
                parameters["path"] = path;
            }

            parameters["caseInsensitive"] = matcher.CaseInsensitive;
            parameters["id"] = fetchId;
            JetMethod fetch = new JetMethod(JetMethod.Fetch, parameters, responseCallback, responseTimeoutMs);

            id = new FetchId(fetchId);
            lock (allFetches)
            {
                allFetches.Add(id);
            }

            return(this.ExecuteMethod(fetch));
        }
Example #4
0
 private void registerFetcher(int fetchId, JetFetcher fetcher)
 {
     lock (openFetches)
     {
         openFetches.Add(fetchId, fetcher);
     }
 }
Example #5
0
        public FetchId fetch(Matcher matcher, Action <JToken> fetchCallback, Action <JToken> responseCallback)
        {
            int        fetchId = Interlocked.Increment(ref fetchIdCounter);
            JetFetcher fetcher = new JetFetcher(fetchCallback);

            registerFetcher(fetchId, fetcher);

            JObject parameters = new JObject();

            parameters["path"]            = fillPath(matcher);
            parameters["caseInsensitive"] = matcher.caseInsensitive;
            parameters["id"] = fetchId;
            int       requestId = Interlocked.Increment(ref requestIdCounter);
            JetMethod fetch     = new JetMethod(JetMethod.FETCH, parameters, requestId, responseCallback);

            executeMethod(fetch, requestId);
            return(new FetchId(fetchId));
        }
Example #6
0
        private void handleFetch(int fetchId, JObject json)
        {
            JetFetcher fetcher = null;

            lock (openFetches)
            {
                if (openFetches.ContainsKey(fetchId))
                {
                    fetcher = openFetches[fetchId];
                }
            }
            if (fetcher != null)
            {
                JToken parameters = json["params"];
                if (parameters.Type != JTokenType.Null)
                {
                    fetcher.callFetchCallback(parameters);
                }
            }
        }