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