Ejemplo n.º 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));
            });
        }
Ejemplo n.º 2
0
 private void OnPubSubEvent(PubSubEventArgs pubSubEventArgs)
 {
     PubSubEvent?.Invoke(this, pubSubEventArgs);
 }