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