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

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

            if (locationResource == null)
            {
                Response response = Response.CreateResponse(exchange.Request, StatusCode.BadRequest);
                exchange.Respond(response);
            }
            else
            {
                locationResource.Name = this.GetNextChildName();
                this.Add(locationResource);
                Response response = Response.CreateResponse(exchange.Request, StatusCode.Changed);
                exchange.Respond(response);
                OnChildCreated(locationResource);
            }
        }
Exemple #3
0
        protected override void DoPost(CoapExchange exchange)
        {
            LocationResource locationResource = LocationResource.Deserialise(exchange.Request);

            if (locationResource == null)
            {
                Response response = Response.CreateResponse(exchange.Request, StatusCode.BadRequest);
                exchange.Respond(response);
            }
            else
            {
                locationResource.Name = this.GetNextChildName();
                this.Add(locationResource);
                Response response = Response.CreateResponse(exchange.Request, StatusCode.Created);
                response.AddOption(Option.Create(OptionType.LocationPath, string.Concat(locationResource.Path, locationResource.Name)));
                exchange.Respond(response);
                OnChildCreated(locationResource);
            }
        }
 public static LocationResource Deserialise(Request request)
 {
     LocationResource result = null;
     string name = request.UriPaths.Last();
     if (!string.IsNullOrEmpty(name) && (request.ContentType == TlvConstant.CONTENT_TYPE_TLV))
     {
         result = new LocationResource();
         using (TlvReader reader = new TlvReader(request.Payload))
         {
             result.Deserialise(reader);
         }
     }
     return result;
 }