Exemple #1
0
        public async Task SendGetTwinRequest(string correlationId)
        {
            try
            {
                using (Metrics.TimeGetTwin(this.Identity.Id))
                {
                    IMessage twin = await this.edgeHub.GetTwinAsync(this.Identity.Id);

                    twin.SystemProperties[SystemProperties.CorrelationId] = correlationId;
                    twin.SystemProperties[SystemProperties.StatusCode]    = ((int)HttpStatusCode.OK).ToString();
                    await this.SendTwinUpdate(twin);

                    Events.ProcessedGetTwin(this.Identity.Id);
                    Metrics.AddGetTwin(this.Identity.Id);
                }
            }
            catch (Exception e)
            {
                Events.ErrorGettingTwin(this.Identity, e);
                await this.HandleTwinOperationException(correlationId, e);
            }
        }
Exemple #2
0
        public async Task <IMessage> GetTwinAsync()
        {
            this.timer.Reset();
            try
            {
                using (Metrics.TimeGetTwin(this.clientId))
                {
                    Twin twin = await this.client.GetTwinAsync();

                    Events.GetTwin(this);
                    Metrics.AddGetTwin(this.clientId);
                    IMessageConverter <Twin> converter = this.messageConverterProvider.Get <Twin>();
                    return(converter.ToMessage(twin));
                }
            }
            catch (Exception ex)
            {
                Events.ErrorGettingTwin(this, ex);
                await this.HandleException(ex);

                throw;
            }
        }