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.
Bug: https://jira.iotivity.org/browse/IOT-1602
Change-Id: I31dcf26a3dc731b4479c9d7a7a4755c7afd07ff8
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14683
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
(cherry picked from commit
76ac4cfd9ffb58a17c93d74c3f6a21b11b07cf50)
Reviewed-on: https://gerrit.iotivity.org/gerrit/15147
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
oc_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,