1 /// Copyright 2016 by Samsung Electronics, Inc.,
3 /// This software is the confidential and proprietary information
4 /// of Samsung Electronics, Inc. ("Confidential Information"). You
5 /// shall not disclose such Confidential Information and shall use
6 /// it only in accordance with the terms of the license agreement
7 /// you entered into with Samsung.
9 using System.Collections.Generic;
11 namespace Tizen.Network.IoTConnectivity
13 public class LiteResource : Resource
18 /// <param name="uri">The uri path of the lite resource</param>
19 /// <param name="types">Resource type</param>
20 /// <param name="policy">Policy of the resource</param>
21 /// <param name="state">Optional State of the resource</param>
22 public LiteResource(string uri, ResourceTypes types, ResourcePolicy policy, State state = null)
23 : base(uri, types, new ResourceInterfaces(new string[] { ResourceInterfaces.DefaultInterface }), policy)
29 /// The state of the lite resource
31 public State State { get; set; }
34 /// The method to accept post request
36 /// <param name="state">The new state of the lite resource</param>
37 /// <returns>true to accept post request, false to reject it</returns>
38 public virtual bool OnPost(State state)
44 /// Called on the get event.
46 /// <param name="request">Request.</param>
47 public sealed override Response OnGet(Request request)
49 Representation representation = new Representation()
52 Interface = Interfaces,
57 Response response = new Response()
59 Representation = representation,
60 Result = ResponseCode.Ok
67 /// Called on the put event.
69 /// <param name="request">Request.</param>
70 public sealed override Response OnPut(Request request)
72 Response response = new Response();
73 response.Result = ResponseCode.Forbidden;
78 /// Called on the post event.
80 /// <param name="request">Request.</param>
81 public sealed override Response OnPost(Request request)
83 if (OnPost(request.Representation.State))
85 State = request.Representation.State;
86 Representation representation = new Representation() {
88 Interface = Interfaces,
93 Response response = new Response() {
94 Representation = representation,
95 Result = ResponseCode.Ok
98 Notify(representation, QualityOfService.High);
102 return new Response()
104 Result = ResponseCode.Error
109 /// Called on the delete event.
111 /// <param name="request">Request.</param>
112 public sealed override Response OnDelete(Request request)
114 Response response = new Response();
115 response.Result = ResponseCode.Forbidden;
120 /// Called on the observing event.
122 /// <param name="request">Request.</param>
123 /// <param name="observerType">Observer type</param>
124 /// <param name="observeId">Observe identifier.</param>
125 public sealed override bool OnObserving(Request request, ObserveType observeType, int observeId)