Beispiel #1
0
        private async Task <string> GetDelat(string thingName)
        {
            try
            {
                GetThingShadowRequest req = new GetThingShadowRequest();
                req.ThingName = thingName;

                GetThingShadowResponse res = await _client.GetThingShadowAsync(req);

                string state = Encoding.UTF8.GetString(res.Payload.ToArray());
                Match  m     = _deltaRgx.Match(state);
                if (m.Success)
                {
                    return(DecodeEncodedNonAsciiCharacters(m.Groups["code"].Value));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Beispiel #2
0
        public ActionResult State(string devName)
        {
            GetThingShadowRequest req = new GetThingShadowRequest();

            req.ThingName = devName;

            GetThingShadowResponse res = _client.GetThingShadow(req);
            string state = Encoding.UTF8.GetString(res.Payload.ToArray());

            return(Content(Request["callback"] + "(" + state + ")"));
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetThingShadowResponse response = new GetThingShadowResponse();

            var ms = new MemoryStream();

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

            return(response);
        }