Example #1
0
        public static async Task <string> Post(this Request request, string payload)
        {
            var coapClientHelper = new CoapClientHelper("Post", request);

            coapClientHelper.Client.PostAsync(payload, coapClientHelper.ResponseCallback, coapClientHelper.FailCallback);
            Response response = await coapClientHelper.GetResponseAsync();

            Log(request.Logger, response);
            return(response.PayloadString);
        }
Example #2
0
        public static async Task <bool> Put <T>(this Request request, T payload)
        {
            string json             = Json.SerializeIgnoreNull(payload);
            var    coapClientHelper = new CoapClientHelper("Put", request);

            coapClientHelper.Client.PutAsync(json, coapClientHelper.ResponseCallback, coapClientHelper.FailCallback);
            Response response = await coapClientHelper.GetResponseAsync();

            Log(request.Logger, response);
            return(response.StatusCode == StatusCode.Changed);
        }
Example #3
0
        public static async Task <T> Get <T>(this Request request)
        {
            var coapClientHelper = new CoapClientHelper("Get", request);

            coapClientHelper.Client.GetAsync(coapClientHelper.ResponseCallback, coapClientHelper.FailCallback);
            Response response = await coapClientHelper.GetResponseAsync();

            T obj = Json.Deserialize <T>(response.PayloadString);

            Log(request.Logger, obj);
            return(obj);
        }