/// <summary> /// Performs unsubscribe request. /// </summary> /// <param name="subscribedUrls">The URLs to which the subscription has been made.</param> /// <param name="callbackUrl">The subscriber's callback URL where unsubscribe intent can be verified.</param> /// <param name="cancellationToken">The cancellation token to cancel operation.</param> /// <returns>The task object representing the asynchronous operation. The result is true if hub has accepted the request, otherwise false.</returns> public async Task <bool> UnsubscribeAsync(WebSubSubscribedUrls subscribedUrls, string callbackUrl, CancellationToken cancellationToken) { if (String.IsNullOrWhiteSpace(subscribedUrls.Topic)) { throw new ArgumentNullException(nameof(subscribedUrls.Topic)); } if (String.IsNullOrWhiteSpace(subscribedUrls.Hub)) { throw new ArgumentNullException(nameof(subscribedUrls.Hub)); } if (String.IsNullOrWhiteSpace(callbackUrl)) { throw new ArgumentNullException(nameof(callbackUrl)); } FormUrlEncodedContent unsubscribeRequestContent = PrepareUnsubscribeRequestContent(subscribedUrls.Topic, callbackUrl); HttpResponseMessage hubResponse = await _httpClient.PostAsync(subscribedUrls.Hub, unsubscribeRequestContent, cancellationToken); return(hubResponse.StatusCode == HttpStatusCode.Accepted); }
/// <summary> /// Performs unsubscribe request. /// </summary> /// <param name="subscribedUrls">The URLs to which the subscription has been made.</param> /// <param name="callbackUrl">The subscriber's callback URL where unsubscribe intent can be verified.</param> /// <returns>The task object representing the asynchronous operation. The result is true if hub has accepted the request, otherwise false.</returns> public Task <bool> UnsubscribeAsync(WebSubSubscribedUrls subscribedUrls, string callbackUrl) { return(UnsubscribeAsync(subscribedUrls, callbackUrl, CancellationToken.None)); }