//private static TransportType s_transportType = TransportType.Http1; //private static TransportType s_transportType = TransportType.Amqp_WebSocket_Only; //private static TransportType s_transportType = TransportType.Mqtt_WebSocket_Only; public static async Task <int> Main(string[] args) { if (string.IsNullOrEmpty(s_deviceConnectionString) && args.Length > 0) { s_deviceConnectionString = args[0]; } using (var deviceClient = DeviceClient.CreateFromConnectionString(s_deviceConnectionString, s_transportType)) { var sample = new MessageSample(deviceClient); await sample.RunSampleAsync().ConfigureAwait(false); } Console.WriteLine("Done.\n"); return(0); }
//private static TransportType s_transportType = TransportType.Mqtt; //private static TransportType s_transportType = TransportType.Http1; //private static TransportType s_transportType = TransportType.Amqp_WebSocket_Only; //private static TransportType s_transportType = TransportType.Mqtt_WebSocket_Only; public static int Main(string[] args) { if (string.IsNullOrEmpty(s_deviceConnectionString) && args.Length > 0) { s_deviceConnectionString = args[0]; } DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(s_deviceConnectionString, s_transportType); if (deviceClient == null) { Console.WriteLine("Failed to create DeviceClient!"); return(1); } var sample = new MessageSample(deviceClient); sample.RunSampleAsync().GetAwaiter().GetResult(); Console.WriteLine("Done.\n"); return(0); }
/// <summary> /// A sample to illustrate how to send telemetry messages. /// </summary> /// <param name="args"> /// Run with `--help` to see a list of required and optional parameters. /// </param> public static async Task <int> Main(string[] args) { // Parse application parameters Parameters parameters = null; ParserResult <Parameters> result = Parser.Default.ParseArguments <Parameters>(args) .WithParsed(parsedParams => { parameters = parsedParams; }) .WithNotParsed(errors => { Environment.Exit(1); }); using var deviceClient = DeviceClient.CreateFromConnectionString( parameters.PrimaryConnectionString, parameters.TransportType); var sample = new MessageSample(deviceClient); await sample.RunSampleAsync(); Console.WriteLine("Done."); return(0); }