public static ServerResource Deserialise(Request request)
        {
            ServerResource result = null;
            string         name   = request.UriPaths.Last();

            if (!string.IsNullOrEmpty(name) && (request.ContentType == TlvConstant.CONTENT_TYPE_TLV))
            {
                result = new ServerResource(name);
                using (TlvReader reader = new TlvReader(request.Payload))
                {
                    result.Deserialise(reader);
                }
            }
            return(result);
        }
Exemple #2
0
        protected override void DoPut(CoapExchange exchange)
        {
            ServerResource serverResource = ServerResource.Deserialise(exchange.Request);

            if (serverResource == null)
            {
                Response response = Response.CreateResponse(exchange.Request, StatusCode.BadRequest);
                exchange.Respond(response);
            }
            else
            {
                this.Add(serverResource);
                Response response = Response.CreateResponse(exchange.Request, StatusCode.Changed);
                exchange.Respond(response);
            }
        }
 public static ServerResource Deserialise(Request request)
 {
     ServerResource result = null;
     string name = request.UriPaths.Last();
     if (!string.IsNullOrEmpty(name) && (request.ContentType == TlvConstant.CONTENT_TYPE_TLV))
     {
         result = new ServerResource(name);
         using (TlvReader reader = new TlvReader(request.Payload))
         {
             result.Deserialise(reader);
         }
     }
     return result;
 }