Ejemplo n.º 1
0
 public string Report(int rate, string devName)
 {
     string jsonStr = string.Format(UPDATE_JSON_TEMPLATE, rate);
     UpdateThingShadowRequest req = new UpdateThingShadowRequest();
     req.ThingName = devName;
     req.Payload = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr));
     UpdateThingShadowResponse res = _client.UpdateThingShadow(req);
     return Encoding.UTF8.GetString(res.Payload.ToArray());
 }
Ejemplo n.º 2
0
        public ActionResult Select(string devName)
        {
            string jsonStr = string.Format(UPDATE_JSON_TEMPLATE, Request["emoji"]);
            UpdateThingShadowRequest req = new UpdateThingShadowRequest();
            req.ThingName = devName;
            req.Payload = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr));
            UpdateThingShadowResponse res =  _client.UpdateThingShadow(req);
            string state = Encoding.UTF8.GetString(res.Payload.ToArray());

            return Content(Request["callback"] + "(" + state + ")");
        }
Ejemplo n.º 3
0
        private async Task Update(string thingName, string emoji, bool isDesired = false)
        {
            try
            {
                string jsonStr = string.Format(UPDATE_JSON_TEMPLATE, isDesired ? "desired" : "reported", emoji);

                UpdateThingShadowRequest req = new UpdateThingShadowRequest();
                req.ThingName = thingName;
                req.Payload = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr));
                UpdateThingShadowResponse res = await _client.UpdateThingShadowAsync(req);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 4
0
 private async Task Connect(string thingName, bool isConnected)
 {
     try
     {
         string jsonStr = string.Format(CONNECT_JSON_TEMPLATE, isConnected ? "true" : "false");
         UpdateThingShadowRequest req = new UpdateThingShadowRequest();
         req.ThingName = thingName;
         req.Payload = new MemoryStream(Encoding.UTF8.GetBytes(jsonStr));
         UpdateThingShadowResponse res = await _client.UpdateThingShadowAsync(req);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateThingShadow operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the UpdateThingShadow operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<UpdateThingShadowResponse> UpdateThingShadowAsync(UpdateThingShadowRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new UpdateThingShadowRequestMarshaller();
            var unmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return InvokeAsync<UpdateThingShadowRequest,UpdateThingShadowResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates the thing shadow for the specified thing.
        /// 
        ///  
        /// <para>
        /// For more information, see <a href="http://docs.aws.amazon.com/iot/latest/developerguide/API_UpdateThingShadow.html">UpdateThingShadow</a>
        /// in the <i>AWS IoT Developer Guide</i>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the UpdateThingShadow service method.</param>
        /// 
        /// <returns>The response from the UpdateThingShadow service method, as returned by IotData.</returns>
        /// <exception cref="Amazon.IotData.Model.ConflictException">
        /// The specified version does not match the version of the document.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.InternalFailureException">
        /// An unexpected error has occurred.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.InvalidRequestException">
        /// The request is not valid.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.MethodNotAllowedException">
        /// The specified combination of HTTP verb and URI is not supported.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.RequestEntityTooLargeException">
        /// The payload exceeds the maximum size allowed.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.ServiceUnavailableException">
        /// The service is temporarily unavailable.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.ThrottlingException">
        /// The rate exceeds the limit.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.UnauthorizedException">
        /// You are not authorized to perform this operation.
        /// </exception>
        /// <exception cref="Amazon.IotData.Model.UnsupportedDocumentEncodingException">
        /// The document encoding is not supported.
        /// </exception>
        public UpdateThingShadowResponse UpdateThingShadow(UpdateThingShadowRequest request)
        {
            var marshaller = new UpdateThingShadowRequestMarshaller();
            var unmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return Invoke<UpdateThingShadowRequest,UpdateThingShadowResponse>(request, marshaller, unmarshaller);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateThingShadow operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the UpdateThingShadow operation on AmazonIotDataClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndUpdateThingShadow
        ///         operation.</returns>
        public IAsyncResult BeginUpdateThingShadow(UpdateThingShadowRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new UpdateThingShadowRequestMarshaller();
            var unmarshaller = UpdateThingShadowResponseUnmarshaller.Instance;

            return BeginInvoke<UpdateThingShadowRequest>(request, marshaller, unmarshaller,
                callback, state);
        }