OCEntityHandlerResult RCSResourceObject::handleRequestSet(
                std::shared_ptr< OC::OCResourceRequest > request)
        {
            assert(request != nullptr);

            auto attrs = getAttributesFromOCRequest(request);
            auto response = invokeHandler(attrs, request, m_setRequestHandler);
            auto requestHandler = response.getHandler();

            assert(requestHandler != nullptr);

            AttrKeyValuePairs replaced = requestHandler->applyAcceptanceMethod(
                    response.getAcceptanceMethod(), *this, attrs);

            for (const auto& attrKeyValPair : replaced)
            {
                std::lock_guard<std::mutex> lock(m_mutexKeyAttributeUpdate);

                auto keyAttrListener = m_keyAttributesUpdatedListeners.find(attrKeyValPair.first);
                if(keyAttrListener != m_keyAttributesUpdatedListeners.end())
                {
                    keyAttrListener-> second(attrKeyValPair.second, attrs[attrKeyValPair.first]);
                }
            }

            autoNotify(!replaced.empty(), m_autoNotifyPolicy);
            return sendResponse(*this, request, response);
        }
Exemplo n.º 2
0
        OCEntityHandlerResult RCSResourceObject::handleRequestGet(
                std::shared_ptr< OC::OCResourceRequest > request)
        {
            assert(request != nullptr);

            auto attrs = getAttributesFromOCRequest(request);

            return sendResponse(*this, request, invokeHandler(attrs, request, m_getRequestHandler));
        }
Exemplo n.º 3
0
        OCEntityHandlerResult RCSResourceObject::handleRequestGet(
                const std::shared_ptr< OC::OCResourceRequest >& request)
        {
            assert(request != nullptr);

            if (requestContainsInterface(request, OC::BATCH_INTERFACE))
            {
                return handleBatchInterfaceGetRequest(request, this);
            }

            auto attrs = getAttributesFromOCRequest(request);

            return sendResponse(*this, request, invokeHandler(attrs, request, m_getRequestHandler));
        }
Exemplo n.º 4
0
        OCEntityHandlerResult RCSResourceObject::handleRequestSet(
                std::shared_ptr< OC::OCResourceRequest > request)
        {
            assert(request != nullptr);

            auto attrs = getAttributesFromOCRequest(request);
            auto response = invokeHandler(attrs, request, m_setRequestHandler);

            auto attrsChanged = applyAcceptanceMethod(response, attrs);

            try
            {
                autoNotify(attrsChanged, m_autoNotifyPolicy);
                return sendResponse(*this, request, response);
            } catch (const RCSPlatformException& e) {
                OC_LOG_V(ERROR, LOG_TAG, "Error : %s ", e.what());
                return OC_EH_ERROR;
            }
        }