public class MainActivity extends AppCompatActivity {\r
\r
private final String TAG = "NS_MAIN_ACTIVITY";\r
- private static final int MESSAGE_SUBSCRIPTION = 1;\r
+ private static final int CONSUMER_SUBSCRIBED = 1;\r
private static final int MESSAGE_SYNC = 2;\r
private static final int MESSAGE_NOTIFICATION = 3;\r
\r
@Override\r
public void handleMessage(Message msg) {\r
switch (msg.what) {\r
- case MESSAGE_SUBSCRIPTION:\r
- String subscriber = (String) msg.obj;\r
- if(subscriber != null)\r
- TvLog.append("Subscriber IP(" + ++subCnt + "): " + subscriber + "\n");\r
+ case CONSUMER_SUBSCRIBED:\r
+ String ConsumerId = (String) msg.obj;\r
+ if(ConsumerId != null)\r
+ TvLog.append("Consumer Subscibed: " + ConsumerId + "\n");\r
break;\r
\r
case MESSAGE_SYNC:\r
String sync = (String) msg.obj;\r
if(sync != null)\r
- TvLog.append("Sync-Read(Msg ID: " + sync + ")\n");\r
+ TvLog.append("SyncInfo Received :" + sync + "\n");\r
break;\r
\r
default:\r
package com.sec.notiproviderexample;\r
\r
import android.content.Context;\r
-import android.os.Handler;\r
+import android.os.*;\r
import android.util.Log;\r
import android.widget.Toast;\r
\r
import org.iotivity.base.PlatformConfig;\r
import org.iotivity.base.QualityOfService;\r
import org.iotivity.base.ServiceType;\r
+import org.iotivity.service.ns.common.Message;\r
import org.iotivity.service.ns.provider.*;\r
import org.iotivity.service.ns.common.*;\r
\r
import java.util.HashMap;\r
\r
public class ProviderProxy\r
- implements ProviderService.OnSubscriptionListener, ProviderService.OnSyncInfoListener{\r
+ implements ProviderService.OnConsumerSubscribedListener, ProviderService.OnMessageSynchronizedListener{\r
\r
private static final String TAG = "NS_PROVIDER_PROXY";\r
\r
\r
private Handler mHandler = null;\r
\r
- private static final int MESSAGE_SUBSCRIPTION = 1;\r
+ private static final int CONSUMER_SUBSCRIBED = 1;\r
private static final int MESSAGE_SYNC = 2;\r
\r
private static final int SYNC_READ = 0;\r
Log.i(TAG, "Start ProviderService -IN");\r
configurePlatform();\r
try{\r
- int result = ioTNotification.Start(policy, this, this);\r
+ int result = ioTNotification.start(this, this, policy, "Info");\r
Log.i(TAG, "Notification Start: " + result);\r
}\r
catch(Exception e){\r
Log.e(TAG, "Exception: stopping presence when terminating NS server: " + e);\r
}\r
try{\r
- int result = ioTNotification.Stop();\r
+ int result = ioTNotification.stop();\r
Log.i(TAG, "Notification Stop: " + result);\r
}\r
catch(Exception e){\r
Log.i(TAG, "SendMessage ProviderService - IN");\r
\r
try{\r
- int result = ioTNotification.SendMessage(notiMessage);\r
+ int result = ioTNotification.sendMessage(notiMessage);\r
Log.i(TAG, "Notification Send Message: " + result);\r
}\r
catch(Exception e){\r
if(msgMap.get(messageId) == SYNC_UNREAD)\r
{\r
try{\r
- ioTNotification.SendSyncInfo(messageId,syncType );\r
+ ioTNotification.sendSyncInfo(messageId, syncType);\r
Log.i(TAG, "Notification Sync " );\r
}\r
catch(Exception e) {\r
public void EnableRemoteService(String servAdd) {\r
Log.i(TAG, "EnableRemoteService ProviderService - IN");\r
try{\r
- int result = ioTNotification.EnableRemoteService(servAdd);\r
+ int result = ioTNotification.enableRemoteService(servAdd);\r
Log.i(TAG, "Notification EnableRemoteService: "+ result );\r
}\r
catch(Exception e) {\r
public void DisableRemoteService(String servAdd) {\r
Log.i(TAG, "DisableRemoteService ProviderService - IN");\r
try{\r
- int result = ioTNotification.DisableRemoteService(servAdd);\r
+ int result = ioTNotification.disableRemoteService(servAdd);\r
Log.i(TAG, "Notification DisableRemoteService: "+ result );\r
}\r
catch(Exception e) {\r
{\r
Log.i(TAG,"AcceptSubscription ProviderService - IN");\r
try{\r
- int result = consumer.AcceptSubscription(consumer, accepted);\r
+ int result = consumer.acceptSubscription(accepted);\r
Log.i(TAG, "Notification AcceptSubscription: "+result );\r
}\r
catch(Exception e) {\r
public void onConsumerSubscribed(Consumer consumer) {\r
Log.i(TAG, "onConsumerSubscribed - IN");\r
AcceptSubscription(consumer, true);\r
+ android.os.Message msg = mHandler.obtainMessage(CONSUMER_SUBSCRIBED,\r
+ "Consumer Id: " + consumer.getConsumerId() );\r
+ mHandler.sendMessage(msg);\r
Log.i(TAG, "onConsumerSubscribed - OUT");\r
}\r
\r
@Override\r
public void onMessageSynchronized(SyncInfo syncInfo) {\r
Log.i(TAG, "Received SyncInfo with messageID: "+syncInfo.getMessageId());\r
+ android.os.Message msg = mHandler.obtainMessage(MESSAGE_SYNC,\r
+ "Message Id: " + syncInfo.getMessageId() );\r
+ mHandler.sendMessage(msg);\r
}\r
\r
public HashMap<String, Integer> getMsgMap() {\r