ListTopicsAsync() 공개 메소드

Initiates the asynchronous execution of the ListTopics operation.
public ListTopicsAsync ( ListTopicsRequest request, System cancellationToken = default(CancellationToken) ) : Task
request ListTopicsRequest Container for the necessary parameters to execute the ListTopics operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
리턴 Task
예제 #1
0
 public Topic CheckSnsTopic(string topicName)
 {
     using (var client = new AmazonSimpleNotificationServiceClient(_credentials))
     {
         return client.ListTopicsAsync().Result.Topics.SingleOrDefault(topic => topic.TopicArn == topicName);
     }
 }
예제 #2
0
 public void DeleteTopic(string topicName)
 {
     using (var client = new AmazonSimpleNotificationServiceClient(_credentials))
     {
         var topic = client.ListTopicsAsync().Result.Topics.SingleOrDefault(t => t.TopicArn == topicName);
         client.DeleteTopicAsync(topic.TopicArn).Wait();
     }
 }
예제 #3
0
        public void ReloadExistingSubscriptions()
        {
            var subscriptions = new List <SubscriptionInfo>();

            using (var client = new AmazonSimpleNotificationServiceClient(this.AwsCredentials, this.AwsRegion)) {
                var request = new ListTopicsRequest();
                ListTopicsResponse        response;
                Task <ListTopicsResponse> ltt;

                do
                {
                    ltt = client.ListTopicsAsync(request);
                    ltt.Wait();
                    response = ltt.Result;

                    foreach (var topic in response.Topics)
                    {
                        var lsRequest = new ListSubscriptionsByTopicRequest()
                        {
                            TopicArn = topic.TopicArn
                        };
                        ListSubscriptionsByTopicResponse        lsResponse;
                        Task <ListSubscriptionsByTopicResponse> lst;

                        do
                        {
                            lst = client.ListSubscriptionsByTopicAsync(lsRequest);
                            lst.Wait();
                            lsResponse = lst.Result;

                            //íterate all subscriptions which are bound to our SubscriptionCallbackUrl...
                            foreach (var subscription in lsResponse.Subscriptions.Where(s => string.Equals(s.Endpoint, this.SubscriptionCallbackUrl, StringComparison.InvariantCultureIgnoreCase)))
                            {
                                //skip pending subscriptions...
                                if (!subscription.SubscriptionArn.Equals(AwsMagicArnForPendingSubscription))
                                {
                                    subscriptions.Add(new SubscriptionInfo(this, subscription.TopicArn, subscription.SubscriptionArn, false));
                                }
                            }

                            lsRequest.NextToken = lsResponse.NextToken;
                        } while (!string.IsNullOrEmpty(lsResponse.NextToken));
                    }

                    request.NextToken = response.NextToken;
                } while (!string.IsNullOrEmpty(response.NextToken));

                lock (_ConfirmedSubscriptions) {
                    _ConfirmedSubscriptions = subscriptions;
                }

                lock (_LocalPendingSubscriptions) {
                    foreach (var lps in _LocalPendingSubscriptions.ToArray())
                    {
                        if (subscriptions.Where(s => (s.TopicArn ?? "") == (lps.TopicArn ?? "")).Any())
                        {
                            _LocalPendingSubscriptions.Remove(lps);
                        }
                    }
                }
            }
        }