コード例 #1
0
        //-------------------------------------------------------------------------------------

        public async Task SubscribeToTopic(string subscriptionId)
        {
            SubscriptionName subscriptionName = new SubscriptionName(_projectId, subscriptionId);
            SubscriberClient subscriberClient = await SubscriberClient.CreateAsync(subscriptionName);

            await subscriberClient.StartAsync((pubsubMessage, cancellationToken) =>
            {
                PubSubEventArgs pubSubEventArgs = new PubSubEventArgs
                {
                    PubsubMessage = pubsubMessage
                };
                OnPubSubEvent(pubSubEventArgs);

                return(Task.FromResult(SubscriberClient.Reply.Ack));
            });
        }
コード例 #2
0
 private void OnPubSubEvent(PubSubEventArgs pubSubEventArgs)
 {
     PubSubEvent?.Invoke(this, pubSubEventArgs);
 }