如何接收实时通知

时间:2018-11-01 07:27:53

标签: cumulocity

我已将手机添加为名为COL-L29的设备。我想从手机接收实时测量结果。我正在以这种方式使用Java API

 public static void main(String[] args) {
        Platform platform = new PlatformImpl(Constants.CUMULOCITY_URL, new CumulocityCredentials(Constants.USERNAME, Constants.PASSWORD));
        InventoryApi inventory = platform.getInventoryApi();
        CepApi cep = platform.getCepApi();

        CepCustomNotificationsSubscriber subscriber = cep.getCustomNotificationsSubscriber();

        Subscription<String> receiver = subscriber.subscribe(channelName, new SubscriptionListener<String, Object>() {

            @Override
            public void onNotification(Subscription<String> arg0, Object arg1) {
                System.out.println("Received notificaiton: "+ arg0 + arg1);


            @Override
            public void onError(Subscription<String> arg0, Throwable arg1) {
                System.out.println("Exception: " + arg0);
            }
        });

    }

我想知道我应该作为channelName传递什么,并且我还需要做其他事情才能接收实时通知吗?

0 个答案:

没有答案