static void Main(string[] args) { var serviceClient = new JsonRestClientAsync("http://g-un--:1337/"); var responseSubject = new BehaviorSubject<Unit>(Unit.Default); responseSubject.Subscribe(_ => { serviceClient.PostAsync<ResourceResponse>( "/async", new ResourceRequest() { ResourceKey = Guid.NewGuid().ToString() }, response => { Console.WriteLine("Data received"); Console.WriteLine(response.ResourceData); responseSubject.OnNext(Unit.Default); }, (response, ex) => { Console.WriteLine("Exception on calling service post method"); Console.WriteLine(ex); responseSubject.OnCompleted(); }); }); Observable.Interval(TimeSpan.FromSeconds(1)) .Subscribe(_ => { var newClient = new JsonRestClientAsync("http://g-un--:1337/"); newClient.PutAsync<object>( "/async", new ResourceRequest() { ResourceKey = Guid.NewGuid().ToString() }, response => { Console.WriteLine("Put was sent!"); }, (response, exception) => { Console.WriteLine(exception); }); }); Console.ReadLine(); }
public static void SendAsync <TResult>(this JsonRestClientAsync client, HttpMethods method, string relativeOrAbsoluteUrl, Action <TResult> onSuccess, Action <TResult, Exception> onError, object request = null) { switch (method) { case HttpMethods.GET: client.GetAsync(relativeOrAbsoluteUrl, onSuccess, onError); break; case HttpMethods.PUT: client.PutAsync(relativeOrAbsoluteUrl, request, onSuccess, onError); break; case HttpMethods.DELETE: client.DeleteAsync(relativeOrAbsoluteUrl, onSuccess, onError); break; case HttpMethods.POST: client.PostAsync(relativeOrAbsoluteUrl, request, onSuccess, onError); break; default: throw new ArgumentOutOfRangeException("HttpMethod not in use"); } }
public PromptServiceClient(JsonRestClientAsync client, string uri) { _uri = uri; _client = client; }
public PromptSelectionServiceClient(JsonRestClientAsync client, string uri) { _uri = uri; _client = client; }
public ReportCatalogServiceClient(JsonRestClientAsync client, string uri) { _uri = uri; _client = client; }
public ChildPromptLevelServiceClient(JsonRestClientAsync client, string uri) { _uri = uri; _client = client; }
public ChildPromptLevelServiceClient(JsonRestClientAsync client, string uri) { _uri = uri; _client = client; }
public ReportCatalogServiceClient(JsonRestClientAsync client, string uri) { _uri = uri; _client = client; }