Exemple #1
0
        public IoTDevice(PSExecutor psExecutor, ConfigurationService config, ILogger logger)
        {
            _logger     = logger.ForContext <IoTDevice>();
            _psExecutor = psExecutor;

            _handlers = new Dictionary <string, MethodCallback>
            {
                { nameof(ListScripts), ListScripts },
                { nameof(ExecuteScript), ExecuteScriptAsyncWrapper }
            };

            string connectionString = config.GetSetting("iothub");

            _deviceClient = DeviceClient.CreateFromConnectionString(connectionString);
        }
Exemple #2
0
        public IoTHubDevice(PSExecutor psExecutor, ConfigurationService config, ILogger logger)
        {
            _logger     = logger.ForContext <IoTHubDevice>();
            _psExecutor = psExecutor;

            _handlers = new Dictionary <string, MethodCallback>
            {
                { nameof(ListScripts), ListScripts },
                { nameof(ExecuteScript), ExecuteScriptAsyncWrapper }
            };

            string connectionString = config.GetSetting("iothub");

            _deviceClient = DeviceClient.CreateFromConnectionString(connectionString);

            IRetryPolicy retryPolicy = new ExponentialBackoff(int.MaxValue,
                                                              TimeSpan.FromSeconds(1),
                                                              TimeSpan.FromSeconds(30),
                                                              TimeSpan.FromSeconds(1));

            _deviceClient.SetRetryPolicy(retryPolicy);
        }