if (responseAttrsObj)
{
- return RESPONSE::create(toNativeAttributes(env.get(), responseAttrsObj), OC_EH_OK,
- errorCode);
+ return RESPONSE::create(toNativeAttributes(env.get(), responseAttrsObj), errorCode);
}
- return RESPONSE::create(OC_EH_OK, errorCode);
+ return RESPONSE::create(errorCode);
}
RCSGetResponse onGetRequest(const RCSRequest& request, const RCSResourceAttributes& attrs,
const JavaGlobalRef& listener)
{
ScopedEnvWrapper env;
- EXPECT_RET(env, "env is null!", RCSGetResponse::create(OC_EH_ERROR, -1));
+ EXPECT_RET(env, "env is null!", RCSGetResponse::create(-1));
try
{
env->ExceptionDescribe();
env->ExceptionClear();
}
- return RCSGetResponse::create(OC_EH_ERROR, -1);
+ return RCSGetResponse::create({ }, -1);
}
RCSSetResponse onSetRequest(const RCSRequest& request, const RCSResourceAttributes& attrs,
const JavaGlobalRef& listener)
{
ScopedEnvWrapper env;
- EXPECT_RET(env, "env is null!", RCSSetResponse::create(OC_EH_ERROR, -1));
+ EXPECT_RET(env, "env is null!", RCSSetResponse::create(-1));
try
{
env->ExceptionDescribe();
env->ExceptionClear();
}
- return RCSSetResponse::create(OC_EH_ERROR, -1);
+ return RCSSetResponse::create(-1);
}
return resourceObj;
}
- catch (const PlatformException& e)
+ catch (const RCSPlatformException& e)
{
LOGE("%s", e.what());
throwPlatformException(env, e);
return valueObj;
}
- catch(const InvalidKeyException& e)
+ catch(const RCSInvalidKeyException& e)
{
return nullptr;
}
auto res = getResource(env, obj);
VERIFY_NO_EXC(env);
- res->setGetRequestHandler(std::bind(onGetRequest, std::placeholders::_1, std::placeholders::_2,
- JavaGlobalRef{ env, listenerObj }));
+ if (listenerObj)
+ {
+ res->setGetRequestHandler(std::bind(onGetRequest, std::placeholders::_1, std::placeholders::_2,
+ JavaGlobalRef{ env, listenerObj }));
+ }
+ else
+ {
+ res->setGetRequestHandler({ });
+ }
}
JNIEXPORT void JNICALL
auto res = getResource(env, obj);
VERIFY_NO_EXC(env);
- res->setSetRequestHandler(std::bind(onSetRequest, std::placeholders::_1, std::placeholders::_2,
- JavaGlobalRef{ env, listenerObj }));
+ if (listenerObj)
+ {
+ res->setSetRequestHandler(std::bind(onSetRequest, std::placeholders::_1,
+ std::placeholders::_2, JavaGlobalRef{ env, listenerObj }));
+ }
+ else
+ {
+ res->setSetRequestHandler({ });
+ }
}
JNIEXPORT void JNICALL
{
res->notify();
}
- catch (const PlatformException& e) {
+ catch (const RCSPlatformException& e) {
throwPlatformException(env, e);
}
}