public async Task WatchMessage(bool follow, int limit, int messageTimeout) { var cc = new IoTHubConsumerCommands(CurrentContext, service); await cc.WatchMessage(follow, limit, messageTimeout); //Console.WriteLine($"WatchMessage with follow {follow}, limit {limit} and timeout {messageTimeout}"); //var config = service.LoadConfig(); //var eu = new EventHubUtilities(); //try //{ // if (follow) // { // //await FollowMessages(messageTimeout); // await eu.FollowMessages(messageTimeout, CurrentContext.ConsumerGroup, CurrentContext.ConnectionString, CurrentContext.EventHubName); // } // else // { // //await WatchMessages(limit, messageTimeout); // await eu.WatchMessagesWithLimit(limit, messageTimeout, CurrentContext.ConsumerGroup, CurrentContext.ConnectionString, CurrentContext.EventHubName); // } //} //catch (Exception ex) //{ // Console.WriteLine($"{ex}"); //} }
public async Task WatchMessage(bool follow, int limit, int messageTimeout, string context) { var listenContext = CurrentContext; if (!String.IsNullOrWhiteSpace(context)) { var config = service.LoadConfig(); if (!config.IoTHubContexts.TryGetValue(context, out listenContext)) { throw new Exception($"Invalid context name: {context}"); } } var cc = new IoTHubConsumerCommands(CurrentContext, service); await cc.WatchMessage(follow, limit, messageTimeout); //Console.WriteLine($"WatchMessage with follow {follow}, limit {limit} and timeout {messageTimeout}"); //var config = service.LoadConfig(); //var eu = new EventHubUtilities(); //try //{ // if (follow) // { // //await FollowMessages(messageTimeout); // await eu.FollowMessages(messageTimeout, CurrentContext.ConsumerGroup, CurrentContext.ConnectionString, CurrentContext.EventHubName); // } // else // { // //await WatchMessages(limit, messageTimeout); // await eu.WatchMessagesWithLimit(limit, messageTimeout, CurrentContext.ConsumerGroup, CurrentContext.ConnectionString, CurrentContext.EventHubName); // } //} //catch (Exception ex) //{ // Console.WriteLine($"{ex}"); //} }