Esempio n. 1
0
        /// <summary>
        /// Initializes the ModuleClient and sets up the callback to receive
        /// messages containing temperature information
        /// </summary>
        static async Task Init()
        {
            MqttTransportSettings mqttSetting = new MqttTransportSettings(TransportType.Mqtt_Tcp_Only);

            ITransportSettings[] settings = { mqttSetting };

            // Open a connection to the Edge runtime
            ioTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(settings);

            await ioTHubModuleClient.OpenAsync();

            Logger.Writer.LogInformation("IoT Hub module client initialized.");

            var moduleTwin = await ioTHubModuleClient.GetTwinAsync();

            await OnDesiredPropertiesUpdate(moduleTwin.Properties.Desired, ioTHubModuleClient);

            await ioTHubModuleClient.SetDesiredPropertyUpdateCallbackAsync(OnDesiredPropertiesUpdate, null);

            // Register callback to be called when a message is received by the module
            await ioTHubModuleClient.SetInputMessageHandlerAsync("input1", PipeMessage, ioTHubModuleClient);

            try
            {
                //starts the execution
                Logger.Writer.LogInformation($"Creating object to long polling...");

                if (sqlPooling != null)
                {
                    sqlPooling.Stop();
                    sqlPooling = null;
                }

                sqlPooling = new PoolingHelper(ioTHubModuleClient,
                                               Settings.Current.ConnectionString, Settings.Current.SqlQuery, Settings.Current.IsSqlQueryJson,
                                               Settings.Current.PoolingIntervalMiliseconds, Settings.Current.MaxBatchSize, Settings.Current.Verbose);
                sqlPooling.Run();
            }
            catch (Exception ex)
            {
                Logger.Writer.LogError(ex, $"Error ocurrer on Init: {ex.ToString()}");
            }
        }
Esempio n. 2
0
 private void Awake()
 {
     PoolingHelper.CreatePool("Fountain", cubePrefab, 300, transform);
 }
Esempio n. 3
0
 private void OnDestroy()
 {
     PoolingHelper.DestroyPool("Fountain");
 }
Esempio n. 4
0
 private void FixedUpdate()
 {
     PoolingHelper.SpawnFromPool("Fountain");
 }