To come on this changeset: All convergences between and server and client observation...
[platform/upstream/iotivity.git] / csdk / stack / include / internal / occlientcb.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 //
21
22 #ifndef OC_CLIENT_CB
23 #define OC_CLIENT_CB
24
25 #include <ocstack.h>
26 #include <occoaptoken.h>
27
28 typedef struct ClientCB {
29     // callback method defined in application address space
30     OCClientResponseHandler callBack;
31     // callback context data
32     void * context;
33     //  when a response is recvd with this token, above callback will be invoked
34     OCCoAPToken * token;
35     // Invocation handle tied to original call to OCDoResource()
36     OCDoHandle handle;
37     // This is used to determine if all responses should be consumed or not. (For now, only pertains to OC_REST_OBSERVE_ALL Vs. OC_REST_OBSERVE functionality)
38     OCMethod method;
39     // This is the sequence identifier the server applies to the invocation tied to 'handle'.
40     uint32_t sequenceNumber;
41     // next node in this list
42     struct ClientCB    *next;
43 } ClientCB;
44
45 //-- AddClientCB -----------------------------------------------------------
46 /** @ingroup ocstack
47  *
48  * This method is used to add a client callback method in cbList.
49  *
50  * @param[out] clientCB
51  *              The resulting node from making this call. Null if out of memory.
52  * @param[in] cb
53  *              address to client callback function.
54  * @param[in] token
55  *              identifier for OTA CoAP comms.
56  * @param[in] handle
57  *              Masked in the public API as an 'invocation handle' - Used for callback management.
58  *
59  * @brief If the handle you're looking for does not exist, the stack will reply with a RST message.
60  *
61  * @retval OC_STACK_OK for Success, otherwise some error value
62  */
63 //------------------------------------------------------------------------
64 OCStackResult AddClientCB(ClientCB** clientCB, OCCallbackData *cbData, OCCoAPToken * token, OCDoHandle handle, OCMethod method);
65
66 //-- DeleteClientCB -----------------------------------------------------------
67 /** @ingroup ocstack
68  *
69  * This method is used to remove a callback node from cbList.
70  *
71  * @param[in] cbNode
72  *              address to client callback node.
73  */
74 //------------------------------------------------------------------------
75 void DeleteClientCB(ClientCB *cbNode);
76
77
78 //-- GetClientCB -----------------------------------------------------------
79 /** @ingroup ocstack
80  *
81  * This method is used to search a cb node in cbList.
82  *
83  * @param[in] token
84  *              token to search for.
85  * @param[in] handle
86  *              handle to search for.
87  *
88  * @brief You can search by token OR by handle. Not both.
89  *
90  * @retval address of the node if found, otherwise NULL
91  */
92 //------------------------------------------------------------------------
93 ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle * handle);
94
95 //-- DeleteClientCBList -----------------------------------------------------------
96 /** @ingroup ocstack
97  *
98  * This method is used to clear the cbList.
99  *
100  */
101 //------------------------------------------------------------------------
102 void DeleteClientCBList();
103
104 #endif //OC_CLIENT_CB