Exemplo n.º 1
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 + ")"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            UpdateThingShadowResponse response = new UpdateThingShadowResponse();

            var ms = new MemoryStream();

            Amazon.Util.AWSSDKUtils.CopyStream(context.Stream, ms);
            ms.Seek(0, SeekOrigin.Begin);
            response.Payload = ms;

            return(response);
        }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 4
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);
            }
        }