Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [leshan-dev] Retrieve Updated content monitored by Observinf a resource on client.

That helped a lot ! Thanks Simon ! 

From: Simon Bernard <contact@xxxxxxxxxxxxxxx>
To: leshan developer discussions <leshan-dev@xxxxxxxxxxx>
Sent: Friday, October 23, 2015 2:08 AM
Subject: Re: [leshan-dev] Retrieve Updated content monitored by Observinf a resource on client.

There is 2 way to be notified of observation.

// listen all observation via the ObservationRegistry
server.getObservationRegistry().addListener(new ObservationRegistryListener() {
     @Override
     public void newValue(Observation observation, LwM2mNode value) {}

    @Override
    public void cancelled(Observation observation) {}

    @Override
    public void newObservation(Observation observation) {}
});


// listen a particular observe request (recently added in master)
ObserveRequest request = new ObserveRequest("/3/0/13");
ObserveResponse response = server.send(client, request, TIMEOUT);
response.getObservation().addListener(new ObservationListener() {
    @Override
    public void newValue(Observation observation, LwM2mNode value) {}

    @Override
    public void cancelled(Observation observation) {}
});

Simon

Le 23/10/2015 01:45, Joey Smith a écrit :


On further investigation I found that ObservationRegistryListener is implemented in EventServlet. Looks like the place to record updates.

 

From: Mariana Nieves <talkjoey@xxxxxxxxx>
To: "leshan-dev@xxxxxxxxxxx" <leshan-dev@xxxxxxxxxxx>
Sent: Thursday, October 22, 2015 3:08 PM
Subject: Retrieve Updated content monitored by Observinf a resource on client.

Hi

Currently I am working on proof of concept using Leshan to recieve log messages from devices on regular basis. We found that Observe request is the best way to go for this approach.
So temporarily, since we don't have a custom object yet(Wakama client not ready yet), on the server side when the client registers, I observe resource 15 on Device in LeshanClientExample.
Here is the Observe code in LeshanServer.java:
  this.clientRegistry.addListener(new ClientRegistryListener() {
   ....
   @Override
         public void registered(final Client client) {
   // TODO observe the client when it is registered.
   observeResource(client);
          }
          ....
 private void observeResource(final Client client){
        ObserveRequest request = new ObserveRequest("/3/0/15");
        LwM2mResponse cResponse = this.send(client, request);
    }
Next I want to capture the change everytime there is a change in the resource and record in a database. I see that in ObjectResource I get content that was updated (in handleGET()). Is that the correct place to retrieve updates from ?
I am trying to find out where in the codebase is the correct place to retrieve updated content ?
Your help will be highly appreciated.

Thanks
J.
         




_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev


_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev



Back to the top