static async Task SubscribeAndReactToEvents(IEventsHubClient hub, Guid correlationId) { await StatusAsync($"Subscribing to events for {correlationId}..."); bool subscribeResult = await hub.SubscribeAsync(correlationId); //subscribeResult.ThrowIfUnsuccessful(); await StatusAsync($"Subscribed!"); Console.WriteLine(); Console.WriteLine("(Press Enter to exit)"); Console.WriteLine(); Console.ReadLine(); Result unsubscribeResult = await hub.UnsubscribeAsync(correlationId); unsubscribeResult.ThrowIfUnsuccessful(); }
static void AttachHubEventHandlers(IEventsHubClient hub) { hub.TokenReceived += (correlationId, token) => StatusAsync($"Token recieved '{token.access_token}' for correlation id {correlationId}."); }