Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[leshan-dev] Receive Observe notifications

I am building a simple prototype based upon the leshan-server-demo included with the repo.  I'm attempting to receive updates from objects that have been observed.  Packet captures show that the updates are making their way to the server, but I'm receiving no notice of them.

Seemingly, the best answers I've googled for are from 2015 - but subsequently changes to the Leshan codebase have made the same technique unworkable.

I've tried using the ObservationService to add an ObservationListener, but that only seems to alert me when the Observe has been requested, not when the endpoint sends up changed values.

    static private void attachListener(final LeshanServer server) {
        System.out.println("Attaching Listener");
        server.getObservationService().addListener(new ObservationListener() {
            @Override
            public void newObservation(Observation observation, Registration registration) {
                System.out.println("New Observation");
            }
            @Override
            public void cancelled(Observation observation) {
                System.out.println("Observation cancellation");
            }
            @Override
            public void onResponse(Observation observation, Registration registration, ObserveResponse response) {
                System.out.println("Observation Response");
            }
            @Override
            public void onError(Observation observation, Registration registration, Exception error) {
                System.out.println("Observation Error");
            }
        });
    }

How should I be listening for observed objects on the Leshan server?

Thank you.

Back to the top