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