uint32_t TTLlevel;
} OCPresence;
-/**
- * Data structure to hold Multicast node identity for resource discovery.
- */
-typedef struct OCMulticastNode
-{
- /** URI of new resource.*/
- char * uri;
-
- /** URI of new resource that entity handler might create.*/
- uint32_t nonce;
-
- /** Linked list; for multicast nodes.*/
- struct OCMulticastNode * next;
-} OCMulticastNode;
-
/**
* Forward declaration of resource type.
*/
*/
void FindAndDeleteClientCB(ClientCB * cbNode);
-/** @ingroup ocstack
- *
- * This method is used to search a multicast presence node from list.
- *
- * @param[in] uri the uri of the request.
- *
- * @return OCMulticastNode
- * The resulting node from making this call. Null if doesn't exist.
- */
-
-OCMulticastNode* GetMCPresenceNode(const char * uri);
-
-/** @ingroup ocstack
- *
- * This method is used to add a multicast presence node to the list.
- * @param[out] outnode the resulting node from making this call. Null if out of memory.
- * @param[in] uri the uri of the server.
- * @param[in] nonce current nonce for the server
- *
- * @return OC_STACK_OK for Success, otherwise some error value
- */
-
-OCStackResult AddMCPresenceNode(OCMulticastNode** outnode, char* uri, uint32_t nonce);
-
#endif //OC_CLIENT_CB
#define TAG "OIC_RI_CLIENTCB"
struct ClientCB *cbList = NULL;
-static OCMulticastNode * mcPresenceNodes = NULL;
OCStackResult
AddClientCB (ClientCB** clientCB, OCCallbackData* cbData,
}
}
}
-
-OCStackResult AddMCPresenceNode(OCMulticastNode** outnode, char* uri, uint32_t nonce)
-{
- if (!outnode)
- {
- return OC_STACK_INVALID_PARAM;
- }
-
- OCMulticastNode *node = (OCMulticastNode*) OICMalloc(sizeof(*node));
- if (node)
- {
- node->nonce = nonce;
- node->uri = uri;
- LL_APPEND(mcPresenceNodes, node);
- *outnode = node;
- return OC_STACK_OK;
- }
- *outnode = NULL;
- return OC_STACK_NO_MEMORY;
-}
-
-OCMulticastNode* GetMCPresenceNode(const char * uri)
-{
- if (uri)
- {
- OCMulticastNode* out = NULL;
- LL_FOREACH(mcPresenceNodes, out)
- {
- if (out->uri && strcmp(out->uri, uri) == 0)
- {
- return out;
- }
- }
- }
- OIC_LOG(INFO, TAG, "MulticastNode Not found !!");
- return NULL;
-}
ResetPresenceTTL(cbNode, maxAge);
cbNode->sequenceNumber = response.sequenceNumber;
-
- // Ensure that a filter is actually applied.
- if( resourceTypeName && cbNode->filterResourceType)
- {
- if(!findResourceType(cbNode->filterResourceType, resourceTypeName))
- {
- goto exit;
- }
- }
}
}
else
{
// This is the multicast case
- OCMulticastNode* mcNode = NULL;
- mcNode = GetMCPresenceNode(presenceUri);
-
- if(mcNode != NULL)
- {
- if(mcNode->nonce == response.sequenceNumber)
- {
- OIC_LOG(INFO, TAG, "No presence change (Multicast)");
- goto exit;
- }
- mcNode->nonce = response.sequenceNumber;
-
- if(maxAge == 0)
- {
- OIC_LOG(INFO, TAG, "Stopping presence");
- response.result = OC_STACK_PRESENCE_STOPPED;
- }
- }
- else
+ OIC_LOG(INFO, TAG, "this is the multicast presence");
+ if (0 == maxAge)
{
- char* uri = OICStrdup(presenceUri);
- if (!uri)
- {
- OIC_LOG(INFO, TAG,
- "No Memory for URI to store in the presence node");
- result = OC_STACK_NO_MEMORY;
- goto exit;
- }
-
- result = AddMCPresenceNode(&mcNode, uri, response.sequenceNumber);
- if(result == OC_STACK_NO_MEMORY)
- {
- OIC_LOG(INFO, TAG,
- "No Memory for Multicast Presence Node");
- OICFree(uri);
- goto exit;
- }
- // presence node now owns uri
+ OIC_LOG(INFO, TAG, "Stopping presence");
+ response.result = OC_STACK_PRESENCE_STOPPED;
}
+ }
-
-
- // Ensure that a filter is actually applied.
- if(resourceTypeName && cbNode->filterResourceType)
+ // Ensure that a filter is actually applied.
+ if (resourceTypeName && cbNode->filterResourceType)
+ {
+ OIC_LOG_V(INFO, TAG, "find resource type : %s", resourceTypeName);
+ if(!findResourceType(cbNode->filterResourceType, resourceTypeName))
{
- OIC_LOG_V(INFO, TAG, "find resource type : %s", resourceTypeName);
- if(!findResourceType(cbNode->filterResourceType, resourceTypeName))
- {
- goto exit;
- }
+ goto exit;
}
}
+
OIC_LOG(INFO, TAG, "Callback for presence");
cbResult = cbNode->callBack(cbNode->context, cbNode->handle, &response);
#ifdef WITH_PRESENCE
OCStackResult OCStartPresence(const uint32_t ttl)
{
+ OIC_LOG(INFO, TAG, "Entering OCStartPresence");
uint8_t tokenLength = CA_MAX_TOKEN_LEN;
OCChangeResourceProperty(
&(((OCResource *)presenceResource.handle)->resourceProperties),
OCStackResult OCStopPresence()
{
+ OIC_LOG(INFO, TAG, "Entering OCStopPresence");
OCStackResult result = OC_STACK_ERROR;
if(presenceResource.handle)
OCStackResult SendPresenceNotification(OCResourceType *resourceType,
OCPresenceTrigger trigger)
{
+ OIC_LOG(INFO, TAG, "SendPresenceNotification");
OCResource *resPtr = NULL;
OCStackResult result = OC_STACK_ERROR;
OCMethod method = OC_REST_PRESENCE;
OCStackResult SendStopNotification()
{
+ OIC_LOG(INFO, TAG, "SendStopNotification");
OCResource *resPtr = NULL;
OCStackResult result = OC_STACK_ERROR;
OCMethod method = OC_REST_PRESENCE;