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 } } }
private void RegisterFetcher(int fetchId, JetFetcher fetcher) { lock (this.openFetches) { this.openFetches.Add(fetchId, fetcher); } }
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)); }
private void registerFetcher(int fetchId, JetFetcher fetcher) { lock (openFetches) { openFetches.Add(fetchId, fetcher); } }
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)); }
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); } } }