//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
-extern OCEntityHandler defaultDeviceHandler;
+extern OCDeviceEntityHandler defaultDeviceHandler;
//-----------------------------------------------------------------------------
// Defines
typedef OCEntityHandlerResult (*OCEntityHandler)
(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest);
+/**
+ * Device Entity handler need to use this call back instead of OCEntityHandler
+ */
+typedef OCEntityHandlerResult (*OCDeviceEntityHandler)
+(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, char* uri);
//-----------------------------------------------------------------------------
// Function prototypes
* OC_STACK_OK - no errors
* OC_STACK_ERROR - stack process error
*/
-OCStackResult OCSetDefaultDeviceEntityHandler(OCEntityHandler entityHandler);
+OCStackResult OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandler entityHandler);
/**
* Create a resource.
}
OCEntityHandlerResult
OCDeviceEntityHandlerCb (OCEntityHandlerFlag flag,
- OCEntityHandlerRequest *entityHandlerRequest)
+ OCEntityHandlerRequest *entityHandlerRequest, char* uri)
{
const char* typeOfMessage;
- OC_LOG_V (INFO, TAG, "Inside device default entity handler - flags: 0x%x", flag);
+ OC_LOG_V (INFO, TAG, "Inside device default entity handler - flags: 0x%x, uri: %s", flag, uri);
if (flag & OC_INIT_FLAG)
{
OC_LOG (INFO, TAG, "Flag includes OC_INIT_FLAG");
OCEntityHandlerRequest *ehRequest = request->entityHandlerRequest;
// At this point we know for sure that defaultDeviceHandler exists
- defaultDeviceHandler(OC_REQUEST_FLAG, ehRequest);
+ defaultDeviceHandler(OC_REQUEST_FLAG, ehRequest, (char*) request->resourceUrl);
ehRequest->resJSONPayloadLen = ehRequest->resJSONPayloadLen -
strlen((char*)ehRequest->resJSONPayload);
#endif
OCMode myStackMode;
-OCEntityHandler defaultDeviceHandler;
+OCDeviceEntityHandler defaultDeviceHandler;
//-----------------------------------------------------------------------------
// Macros
#endif
-OCStackResult OCSetDefaultDeviceEntityHandler(OCEntityHandler entityHandler)
+OCStackResult OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandler entityHandler)
{
defaultDeviceHandler = entityHandler;
{
if(request)
{
+ std::cout << "In Default Entity Handler, uri received: "
+ << request->getResourceUri() << std::endl;
+
if(request->getRequestHandlerFlag() == RequestHandlerFlag::RequestFlag)
{
if(request->getRequestType() == "GET")
const std::string BATCH_INTERFACE = "oc.mi.b";
typedef std::function<void(std::shared_ptr<OCResource>)> FindCallback;
- typedef std::function<void(const std::shared_ptr<OCResourceRequest>, const std::shared_ptr<OCResourceResponse>)> EntityHandler;
+ typedef std::function<void(const std::shared_ptr<OCResourceRequest>,
+ const std::shared_ptr<OCResourceResponse>)> EntityHandler;
typedef std::function<void(OCStackResult, const unsigned int)> SubscribeCallback;
typedef std::function<void(const OCRepresentation&, const int)> GetCallback;
typedef std::function<void(const OCRepresentation&, const int)> PutCallback;
const QueryParamsMap& getQueryParameters() const {return m_queryParameters;}
/**
- * Retrieves the request handler flag type. This can be either INIT flag or
+ * Retrieves the request handler flag type. This can be either INIT flag or
* REQUEST flag or OBSERVE flag.
* NOTE:
- * INIT indicates that the vendor's entity handler should go and perform
+ * INIT indicates that the vendor's entity handler should go and perform
* initialization operations
- * REQUEST indicates that it is a request of certain type (GET/PUT/POST/DELETE)
+ * REQUEST indicates that it is a request of certain type (GET/PUT/POST/DELETE)
* and entity handler needs to perform corresponding operations
- * OBSERVE indicates that the request is of type Observe and entity handler
+ * OBSERVE indicates that the request is of type Observe and entity handler
* needs to perform corresponding operations
* @return int type of request flag
*/
const OCRepresentation& getResourceRepresentation() const {return m_representation;}
/**
- * Provides the entire resource representation
- * @return OCRepresentation reference which provides entire resource information
+ * @return ObservationInfo reference provides observation information
*/
const ObservationInfo& getObservationInfo() const {return m_observationInfo;}
+ /**
+ * sets resource uri
+ * @param resourceUri specifies the resource uri
+ */
+ void setResourceUri(const std::string resourceUri)
+ {
+ m_resourceUri = resourceUri;
+ }
+
+ /**
+ * gets resource uri
+ * @return std::string resource uri
+ */
+ std::string getResourceUri(void)
+ {
+ return m_resourceUri;
+ }
+
+
private:
std::string m_requestType;
+ std::string m_resourceUri;
QueryParamsMap m_queryParameters;
int m_requestHandlerFlag;
OCRepresentation m_representation;
class OutOfProcServerWrapper : public IServerWrapper
{
public:
- OutOfProcServerWrapper(OC::OCPlatform& owner, PlatformConfig cfg)
+ OutOfProcServerWrapper(OC::OCPlatform& owner, PlatformConfig cfg)
: IServerWrapper(owner)
{};
}
OCEntityHandlerResult DefaultEntityHandlerWrapper(OCEntityHandlerFlag flag,
- OCEntityHandlerRequest * entityHandlerRequest)
+ OCEntityHandlerRequest * entityHandlerRequest,
+ char* uri)
{
// TODO we need to have a better way of logging (with various levels of logging)
std::clog << "\nIn Default device entity handler wrapper: " << endl;
formResourceRequest(flag, entityHandlerRequest, pRequest);
+ // TODO : This is currently being done only for Device entity handler
+ // we will need to do the similar things for regular entity handler
+ pRequest->setResourceUri(std::string(uri));
+
if(defaultDeviceEntityHandler)
{
defaultDeviceEntityHandler(pRequest, pResponse);
return result;
}
- OCStackResult InProcServerWrapper::setDefaultDeviceEntityHandler(EntityHandler entityHandler)
+ OCStackResult InProcServerWrapper::setDefaultDeviceEntityHandler
+ (EntityHandler entityHandler)
{
OCStackResult result = OC_STACK_ERROR;