Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cf-dev] How to get observe response as variable

Hello,

 

   Currently i am trying to get some observe data from my CoAP server nodes. I am using the code in CoapClientExample.java “\demo-apps\api-demo\src\org\eclipse\californium\examples\”. It Works perfectly and prints values on screen. However i want to access content variable.

 

*************************************

CoapObserveRelation relation = client.observe(

                new CoapHandler() {

                               @Override public void onLoad(CoapResponse response) {

                                               String content = response.getResponseText();

                                               System.out.println("NOTIFICATION: " + content);

                               }

                              

                               @Override public void onError() {

                                               System.err.println("OBSERVING FAILED (press enter to exit)");

                               }

                });

 

// “This is where i  want to Access content variable”

// i.e. :

System.out.println(content);

 

*************************************

 

I have little experience with java. There’s no global variables or pointers like C/C++. How can i make it work ?

 

Thank you, Sedat Bilgili.


Back to the top