ca_mutex_unlock(g_mutexObjectList);
CHECKFD(sockfd);
+
+ // pass the connection information to CA Common Layer.
+ if (g_connectionCallback)
+ {
+ g_connectionCallback(&(svritem->sep.endpoint), true);
+ }
}
}
*/
OCStackResult DeleteObserverUsingToken (CAToken_t token, uint8_t tokenLength);
+ /**
+ * Delete observer with device address from list of observers.
+ * Free memory that was allocated for the observer in the list.
+ *
+ * @param devAddr Device's address.
+ *
+ * @return ::OC_STACK_OK on success, some other value upon failure.
+ */
+OCStackResult DeleteObserverUsingDevAddr(const OCDevAddr *devAddr);
+
/**
* Search the list of observers for the specified token.
*
return OC_STACK_OK;
}
+OCStackResult DeleteObserverUsingDevAddr(const OCDevAddr *devAddr)
+{
+ if (!devAddr)
+ {
+ return OC_STACK_INVALID_PARAM;
+ }
+
+ ResourceObserver *out = NULL;
+ ResourceObserver *tmp = NULL;
+ LL_FOREACH_SAFE(g_serverObsList, out, tmp)
+ {
+ if (out)
+ {
+ if ((strcmp(out->devAddr.addr, devAddr->addr) == 0)
+ && out->devAddr.port == devAddr->port)
+ {
+ OIC_LOG_V(INFO, TAG, "deleting observer id %u with %s:%u",
+ out->observeId, out->devAddr.addr, out->devAddr.port);
+ OCStackFeedBack(out->token, out->tokenLength, OC_OBSERVER_NOT_INTERESTED);
+ }
+ }
+ }
+
+ return OC_STACK_OK;
+}
+
void DeleteObserverList()
{
ResourceObserver *out = NULL;
{
g_connectionHandler(info, isConnected);
}
+
+ /*
+ * If the client observes one or more resources over a reliable connection,
+ * then the CoAP server (or intermediary in the role of the CoAP server)
+ * MUST remove all entries associated with the client endpoint from the lists
+ * of observers when the connection is either closed or times out.
+ */
+ if (!isConnected)
+ {
+ OCDevAddr devAddr = { OC_DEFAULT_ADAPTER };
+ CopyEndpointToDevAddr(info, &devAddr);
+
+ // remove observer list with remote device address.
+ DeleteObserverUsingDevAddr(&devAddr);
+ }
}
void OCSetNetworkMonitorHandler(CAAdapterStateChangedCB adapterHandler,