Commit 61241563 authored by KIM JungYong's avatar KIM JungYong Committed by Uze Choi

Fix bug for can not callback on consumer cpp layer.

When starting consumer service, getTopic callback fisrt
and then discover callback due to can not call both changed callback and discover callback.
because when callback getTopic, NSProvider instance does not set the listener,
and when callback discover after, NSProvider instance already create, so can not callback discover.
This point is invalid logic on CPP layer.

With this patch, altough call getTopic first, can callback discover callback.

Change-Id: Ib7a3c8cf3e78edf24d0251227c5d3c225c3ba3a4
Signed-off-by: default avatarKIM JungYong <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13855Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
Tested-by: default avatarUze Choi <uzchoi@samsung.com>
parent 8b776fc5
......@@ -72,6 +72,7 @@ namespace OIC
{
NS_LOG(DEBUG, "Provider with same Id exists. updating the old Provider data");
auto changeCallback = oldProvider->getProviderStateReceivedCb();
auto prevState = oldProvider->getProviderState();
oldProvider->setProviderState((NSProviderState)state);
if (state == NS_ALLOW)
{
......@@ -81,6 +82,14 @@ namespace OIC
NS_LOG(DEBUG, "initiating the callback for Response : NS_ALLOW");
changeCallback((NSProviderState)state);
}
else
{
oldProvider->setProviderSubscribedState(NSProviderSubscribedState::SUBSCRIBED);
auto discoveredCallback = NSConsumerService::getInstance()->getProviderDiscoveredCb();
discoveredCallback(oldProvider);
auto changeCallback = oldProvider->getProviderStateReceivedCb();
changeCallback(prevState);
}
}
else if (state == NS_DENY)
{
......
......@@ -21,6 +21,7 @@
#include <iostream>
#include <stdlib.h>
#include <cstdint>
#include <limits>
#include "NSCommon.h"
#include "NSProviderService.h"
#include "NSUtils.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment