NS_LOG(DEBUG, "NSEntityHandlerTopicCb - OC_REST_GET");\r
\r
// send consumer's interesting topic list if consumer id exists\r
- // otherwise send created / updated topic list\r
-\r
+ // otherwise send registered topic list\r
NSPushQueue(TOPIC_SCHEDULER, TASK_SEND_TOPICS,\r
NSCopyOCEntityHandlerRequest(entityHandlerRequest));\r
\r
// Receive interesting topic list from consumers\r
NS_LOG(DEBUG, "NSEntityHandlerTopicCb - OC_REST_POST");\r
\r
- // Send topic updated message(id=TOPIC) to the consumer who request to post.\r
+ // Send topic notice message(id = TOPIC) to the consumer \r
+ // which requests to post.\r
NSPushQueue(TOPIC_SCHEDULER, TASK_SUBSCRIBE_TOPICS,\r
NSCopyOCEntityHandlerRequest(entityHandlerRequest));\r
\r
return NS_OK;\r
}\r
\r
+NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)\r
+{\r
+ NS_LOG(DEBUG, "NSSendTopicList - IN");\r
+\r
+ char * id = NSGetValueFromQuery(OICStrdup(entityHandlerRequest->query), NS_QUERY_CONSUMER_ID);\r
+ if(!id)\r
+ {\r
+ NS_LOG(DEBUG, "Send registered topic list");\r
+ //TODO: get registered topic list\r
+ }\r
+ else\r
+ {\r
+ NS_LOG(DEBUG, "Send subscribed topic list to consumer");\r
+ //TODO: get subscribed topic list for consumer\r
+ }\r
+\r
+ // make response for the Get Request\r
+ OCEntityHandlerResponse response;\r
+ response.numSendVendorSpecificHeaderOptions = 0;\r
+ memset(response.sendVendorSpecificHeaderOptions, 0,\r
+ sizeof response.sendVendorSpecificHeaderOptions);\r
+ memset(response.resourceUri, 0, sizeof response.resourceUri);\r
+\r
+ OCRepPayload* payload = OCRepPayloadCreate();\r
+ if (!payload)\r
+ {\r
+ NS_LOG(ERROR, "payload is NULL");\r
+ return NS_ERROR;\r
+ }\r
+\r
+ OCRepPayloadSetUri(payload, NS_COLLECTION_TOPIC_URI);\r
+ OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_CONSUMER_ID, id);\r
+ // TODO: add PayLoadSet with topic list got above\r
+\r
+ response.requestHandle = entityHandlerRequest->requestHandle;\r
+ response.resourceHandle = entityHandlerRequest->resource;\r
+ response.persistentBufferFlag = 0;\r
+ response.ehResult = OC_EH_OK;\r
+ response.payload = (OCPayload *) payload;\r
+\r
+ // Send Response\r
+ if (OCDoResponse(&response) != OC_STACK_OK)\r
+ {\r
+ NS_LOG(ERROR, "Fail to response topic list");\r
+ return NS_ERROR;\r
+ }\r
+ OCRepPayloadDestroy(payload);\r
+ NSFreeOCEntityHandlerRequest(entityHandlerRequest);\r
+\r
+ NS_LOG(DEBUG, "NSSendTopicList - OUT");\r
+ return NS_OK;\r
+}\r
+\r
bool NSIsTopicSubscribed(char * consumerId, char * topic)\r
{\r
//TODO: implement function\r
{\r
case TASK_SEND_TOPICS:\r
NS_LOG(DEBUG, "CASE TASK_SEND_TOPICS : ");\r
+ NSSendTopicList((OCEntityHandlerRequest*) node->taskData);\r
break;\r
case TASK_SUBSCRIBE_TOPICS:\r
NS_LOG(DEBUG, "CASE TASK_SUBSCRIBE_TOPICS : ");\r