Coder Social home page Coder Social logo

Comments (6)

szysas avatar szysas commented on August 29, 2024

We could start discussing this issue.

I have a proposal such as:

To have a single observation listener for all subscriptions such as:

public interface ObservationListener {
   // return false to will terminate observation 
   boolean onObservation(String resourceUriPath, CoapResponse observation);
}

And observation store interface, that could be implemented as database:

public interface ObservationRelationsStore {
    void add(CoapRequest obsReq);
    String getUriPathOrNull(SeparateResponse obs);
    void remove(SeparateResponse obs);

from java-coap.

sbernard31 avatar sbernard31 commented on August 29, 2024

It's hard to me to see how this will be used as I didn't know java-coap so well for now.

But I can try to provide some feedback. (keep in mind that I maybe don't really get what you have in mind)

  1. About ObservationListener : not sure resourceUriPath is enough to identify a observation ? I feel that we need the token (maybe it is available in CoapResponse ?) and probably a kind of peer identifier (maybe it is available in CoapResponse transport context ?) OR CoapResponse should be replace by SeparatedResponse` ?

  2. About add(CoapRequest obsReq), to store all information I need, I will probably need to attach some userData to CoapRequest? Maybe I will be able to do that using transport context ?

  3. About getUriPathOrNull(SeparateResponse obs), remove(SeparateResponse obs), I guess I should be able to find observe relation from identifier based token of Separated Response + peer Identity from SeparatedResponse transport context.

from java-coap.

szysas avatar szysas commented on August 29, 2024
  1. About ObservationListener : not sure resourceUriPath is enough to identify a observation ? I feel that we need the token (maybe it is available in CoapResponse ?) and probably a kind of peer identifier (maybe it is available in CoapResponse transport context ?) OR CoapResponse should be replace by SeparatedResponse` ?

Good point, it should be SeparatedResponse

public interface ObservationListener {
   // return false to will terminate observation 
   boolean onObservation(String resourceUriPath, SeparatedResponse observation);
}
  1. About add(CoapRequest obsReq), to store all information I need, I will probably need to attach some userData to CoapRequest? Maybe I will be able to do that using transport context ?

Well, that will be called by server when handling new subscription (GET with obs header). What kind of user data are you thinking of? Would it be possible to retrieve such meta data by implementation class of ObservationRelationsStore?

  1. About getUriPathOrNull(SeparateResponse obs), remove(SeparateResponse obs), I guess I should be able to find observe relation from identifier based token of Separated Response + peer Identity from SeparatedResponse transport context.

Yes, all those info will be available.

from java-coap.

sbernard31 avatar sbernard31 commented on August 29, 2024

Well, that will be called by server when handling new subscription (GET with obs header). What kind of user data are you thinking of? Would it be possible to retrieve such meta data by implementation class of ObservationRelationsStore?

I will probably create a kind of adapter which will implement ObservationRelationsStore interface with an internal reference to Leshan RegistrationStore.

When void add(CoapRequest obsReq); will be called, internally I will call :

https://github.com/eclipse/leshan/blob/33cbe86744774f3a81f215606425a4b3f5d12168/leshan-server-core/src/main/java/org/eclipse/leshan/server/registration/RegistrationStore.java#L100-L109

But I need the registrationId (In LWM2M the observe relation is tied to Registration concept).
When I send the ObserveRequest, I know I send it to the device with the given registration so when the relation is added to the store I must tied it to that registration.

That's why I would like to add the registration id to the coap request when I translate the LWM2M request to CoAP request, so I can find it back on ObservationRelationsStore.add

I hope I'm almost clear 😁

from java-coap.

szysas avatar szysas commented on August 29, 2024

That's why I would like to add the registration id to the coap request when I translate the LWM2M request to CoAP request, so I can find it back on ObservationRelationsStore.add

I hope I'm almost clear

Adding registration-id (or any other meta data) is possible through TransportContext so I don't see issue there.

Yes, that was very clear.

from java-coap.

szysas avatar szysas commented on August 29, 2024

Minor updates to interfaces:

public interface ObservationRelationsStore {
    void add(CoapRequest obsReq);       // contains: Uri-path, Token, IP address, and TransportContext
    void remove(SeparateResponse obs);  // contains: Token, IP address and TransportContext
    Optional<String> resolveUriPath(SeparateResponse obs); // contains: Token, IP address and TransportContext
public interface ObservationListener {
    /**
     * Handles incoming observation
     * @return if false then server will terminate observation by sending RESET
     */
    boolean onObservation(String resourceUriPath, SeparateResponse observation);

from java-coap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.