}
/**
+ * Request to subscribe to MQ server
+ * @param servAdd - servAdd combined with IP address and port number and MQ broker uri using delimiter :
+ * @param topicName - the interest Topic name for subscription
+ * @return result code
+ */
+ public int subscribeMQService(String servAdd, String topicName) throws NSException
+ {
+ return nativeSubscribeMQService(servAdd, topicName);
+ }
+
+ /**
* Request discovery manually
*/
public void rescanProvider() throws NSException
private native void nativeStop() throws NSException;
private native void nativeEnableRemoteService(String serverAddress) throws NSException;
- private native void nativeRescanProvider() throws NSException;
+ private native int nativeSubscribeMQService(String servAdd, String topicName) throws NSException;
+ private native void nativeRescanProvider() throws NSException;
}
}
/**
+ * Request to subscribe to MQ server
+ * @param servAdd - servAdd combined with IP address and port number and MQ broker uri using delimiter :
+ * @param topicName - the interest Topic name for subscription
+ * @return result code
+ */
+ public int subscribeMQService(String servAdd, String topicName) throws NSException
+ {
+ return nativeSubscribeMQService(servAdd, topicName);
+ }
+
+ /**
* Add topic to topic list
* @param topicName - Topic name to add
* @return :: result code
public native Message nativeCreateMessage() throws NSException;
public native int nativeEnableRemoteService(String servAdd) throws NSException;
public native int nativeDisableRemoteService(String servAdd) throws NSException;
+ public native int nativeSubscribeMQService(String servAdd, String topicName) throws NSException;
public native int nativeRegisterTopic(String topicName) throws NSException;
public native int nativeUnregisterTopic(String topicName) throws NSException;
public native TopicsList nativeGetRegisteredTopicList() throws NSException;
return (jint) res;\r
}\r
\r
+JNIEXPORT jint JNICALL\r
+Java_org_iotivity_service_ns_consumer_ConsumerService_nativeSubscribeMQService\r
+(JNIEnv *env, jobject jObj, jstring jserverAddress, jstring jTopicName)\r
+{\r
+ LOGD("ConsumerService: nativeSubscribeMQService - IN");\r
+ if (!jserverAddress)\r
+ {\r
+ ThrowNSException(NS_ERROR, "Server Address Can't be NULL");\r
+ return (jint) OIC::Service::NSResult::ERROR;\r
+ }\r
+ if (!jTopicName)\r
+ {\r
+ ThrowNSException(NS_ERROR, "TopicName Can't be NULL");\r
+ return (jint) OIC::Service::NSResult::ERROR;\r
+ }\r
+\r
+ const char *address = env->GetStringUTFChars( jserverAddress, NULL);\r
+ std::string servAddress(address);\r
+ const char *topic = env->GetStringUTFChars( jTopicName, NULL);\r
+ std::string topicName(topic);\r
+\r
+ OIC::Service::NSResult result =\r
+ OIC::Service::NSConsumerService::getInstance()->subscribeMQService(\r
+ servAddress, topicName);\r
+ if (result != OIC::Service::NSResult::OK)\r
+ {\r
+ LOGE("Fail to Subscribe to MQ Service");\r
+ }\r
+ env->ReleaseStringUTFChars(jserverAddress, address);\r
+ env->ReleaseStringUTFChars(jTopicName, topic);\r
+ LOGD("ConsumerService: nativeSubscribeMQService - OUT");\r
+ return (jint) result;\r
+}\r
+\r
JNIEXPORT void JNICALL Java_org_iotivity_service_ns_consumer_ConsumerService_nativeRescanProvider\r
(JNIEnv *env, jobject jObj)\r
{\r
\r
/*\r
* Class: org_iotivity_service_ns_consumer_ConsumerService\r
+ * Method: nativeSubscribeMQService\r
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I\r
+ */\r
+JNIEXPORT jint JNICALL\r
+Java_org_iotivity_service_ns_consumer_ConsumerService_nativeSubscribeMQService\r
+(JNIEnv *, jobject, jstring, jstring);\r
+\r
+/*\r
+ * Class: org_iotivity_service_ns_consumer_ConsumerService\r
* Method: nativeRescanProvider\r
* Signature: ()V\r
*/\r
return (jint) result;
}
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_ns_provider_ProviderService_nativeSubscribeMQService
+(JNIEnv *env, jobject jObj, jstring jserverAddress, jstring jTopicName)
+{
+ LOGD("JNIProviderService: nativeSubscribeMQService - IN");
+ if (!jserverAddress)
+ {
+ ThrowNSException(NS_ERROR, "Server Address Can't be NULL");
+ return (jint) OIC::Service::NSResult::ERROR;
+ }
+ if (!jTopicName)
+ {
+ ThrowNSException(NS_ERROR, "TopicName Can't be NULL");
+ return (jint) OIC::Service::NSResult::ERROR;
+ }
+
+ const char *address = env->GetStringUTFChars( jserverAddress, NULL);
+ std::string servAddress(address);
+ const char *topic = env->GetStringUTFChars( jTopicName, NULL);
+ std::string topicName(topic);
+
+ OIC::Service::NSResult result =
+ OIC::Service::NSProviderService::getInstance()->subscribeMQService(
+ servAddress, topicName);
+ if (result != OIC::Service::NSResult::OK)
+ {
+ LOGE("Fail to Subscribe to MQ Service");
+ }
+ env->ReleaseStringUTFChars(jserverAddress, address);
+ env->ReleaseStringUTFChars(jTopicName, topic);
+ LOGD("JNIProviderService: nativeSubscribeMQService - OUT");
+ return (jint) result;
+}
+
JNIEXPORT jint JNICALL Java_org_iotivity_service_ns_provider_ProviderService_nativeRegisterTopic
(JNIEnv *env, jobject jObj, jstring jTopicName)
{
/*
* Class: org_iotivity_service_ns_provider_ProviderService
+ * Method: nativeSubscribeMQService
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL
+Java_org_iotivity_service_ns_provider_ProviderService_nativeSubscribeMQService
+(JNIEnv *, jobject, jstring, jstring);
+
+/*
+ * Class: org_iotivity_service_ns_provider_ProviderService
* Method: nativeRegisterTopic
* Signature: (Ljava/lang/String;)I
*/
if env.get('WITH_CLOUD') == True:
notification_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
+with_mq = env.get('WITH_MQ')
+if 'SUB' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
+ print "MQ SUB support"
+
+if 'PUB' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
+ print "MQ PUB support"
+
+if 'BROKER' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
+ print "MQ Broker support"
######################################################################
# Source files and Targets for Consumer
######################################################################
NSResult enableRemoteService(const std::string &serverAddress);\r
\r
/**\r
+ * Request to subscribe to remote MQ address as parameter.\r
+ * @param[in] server address combined with IP address and port number and MQ broker uri using delimiter :\r
+ * @param[in] topicName the interest Topic name for subscription.\r
+ * @return ::NS_OK or result code of NSResult\r
+ */\r
+ NSResult subscribeMQService(const std::string &serverAddress, const std::string &topicName);\r
+\r
+ /**\r
* Request discovery manually\r
*/\r
void rescanProvider();\r
return result;\r
}\r
\r
+ NSResult NSConsumerService::subscribeMQService(const std::string &serverAddress,\r
+ const std::string &topicName)\r
+ {\r
+ NS_LOG(DEBUG, "subscribeMQService - IN");\r
+ NS_LOG_V(DEBUG, "Server Address : %s", serverAddress.c_str());\r
+ NSResult result = NSResult::ERROR;\r
+#ifdef WITH_MQ\r
+ result = (NSResult) NSConsumerSubscribeMQService(\r
+ serverAddress.c_str(), topicName.c_str());\r
+#else\r
+ NS_LOG(ERROR, "MQ Services feature is not enabled in the Build");\r
+ (void) serverAddress;\r
+ (void) topicName;\r
+#endif\r
+ NS_LOG(DEBUG, "subscribeMQService - OUT");\r
+ return result;\r
+ }\r
+\r
void NSConsumerService::rescanProvider()\r
{\r
NS_LOG(DEBUG, "rescanProvider - IN");\r
getProviderId().c_str());\r
NSResult result = (NSResult) NSConsumerUpdateTopicList(getProviderId().c_str(), topicLL);\r
\r
- if(topicLL)\r
+ if (topicLL)\r
{\r
- NSTopicLL * iter = topicLL;\r
- NSTopicLL * following = NULL;\r
+ NSTopicLL *iter = topicLL;\r
+ NSTopicLL *following = NULL;\r
\r
while (iter)\r
{\r
following = iter->next;\r
- if(iter)\r
+ if (iter)\r
{\r
NSOICFree(iter->topicName);\r
iter->next = NULL;\r
if env.get('WITH_CLOUD') == True:
notification_sample_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
+with_mq = env.get('WITH_MQ')
+if 'SUB' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
+ print "MQ SUB support"
+
+if 'PUB' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
+ print "MQ PUB support"
+
+if 'BROKER' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
+ print "MQ Broker support"
+
if env.get('WITH_TCP') == True:
notification_sample_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
if env.get('SECURED') == '1':
if env.get('WITH_CLOUD') == True:
notification_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
+with_mq = env.get('WITH_MQ')
+if 'SUB' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
+ print "MQ SUB support"
+
+if 'PUB' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
+ print "MQ PUB support"
+
+if 'BROKER' in with_mq:
+ notification_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
+ print "MQ Broker support"
######################################################################
# Source files and Targets for Provider
######################################################################
NSResult disableRemoteService(const std::string &serverAddress);\r
\r
/**\r
+ * Request to subscribe to remote MQ address as parameter.\r
+ * @param[in] server address combined with IP address and port number and MQ broker uri using delimiter :\r
+ * @param[in] topicName the interest Topic name for subscription.\r
+ * @return ::NS_OK or result code of NSResult\r
+ */\r
+ NSResult subscribeMQService(const std::string &serverAddress, const std::string &topicName);\r
+\r
+ /**\r
* Send notification message to all subscribers\r
* @param[in] msg Notification message including id, title, contentText\r
* @return :: result code of Provider Service\r
return result;\r
}\r
\r
+ NSResult NSProviderService::subscribeMQService(const std::string &serverAddress,\r
+ const std::string &topicName)\r
+ {\r
+ NS_LOG(DEBUG, "subscribeMQService - IN");\r
+ NS_LOG_V(DEBUG, "Server Address : %s", serverAddress.c_str());\r
+ NSResult result = NSResult::ERROR;\r
+#ifdef WITH_MQ\r
+ result = (NSResult) NSProviderSubscribeMQService(\r
+ serverAddress.c_str(), topicName.c_str());\r
+#else\r
+ NS_LOG(ERROR, "MQ Services feature is not enabled in the Build");\r
+ (void) serverAddress;\r
+ (void) topicName;\r
+#endif\r
+ NS_LOG(DEBUG, "subscribeMQService - OUT");\r
+ return result;\r
+ }\r
+\r
NSResult NSProviderService::sendMessage(NSMessage *msg)\r
{\r
NS_LOG(DEBUG, "sendMessage - IN");\r