eclipse-californium / californium

CoAP/DTLS Java Implementation
https://www.eclipse.org/californium/
Other
730 stars 367 forks source link

How to listen observe relation lifecycle ? #2221

Closed sbernard31 closed 8 months ago

sbernard31 commented 9 months ago

About cf 3.x, To implement LWM2M write attributes at client side, I need to alter default coap observe behavior at coap server side .

I almost succeed to get a working version. (even if I don't really like the code I written in Leshan :disappointed:) Anyway, to do that I have kind of store which hold some data for each relation for each relation. Those data contain how the behavior is altered.

The last (known) remaining problem: My current issue is I don't find a right way to do housekeeping of those data. Ideally I should be able to remove my data when observe relation is removed too.

Any Idea ?

sbernard31 commented 9 months ago

As I didn't find a way to listen observe relation lifecycle, I fallback to a not Ideal solution by hooking some housekeeping code in several places. I tried to hook to all the cases which could lead to end an observe relation at coap server (RST on notification, notification with error code, receive observe with observe option =1). Hoping I didn't missed an existing one OR new one will not be added.

Anyway, If you have better idea, please let me know.

boaks commented 8 months ago

ResourceObserver. Not sure, if that has a chance to work on removing the resource itself. I'm in vacation and will be back next week. If it doesn't work, maybe we consider an updated API for that with Cf 4.0 (and start with that I hope on April, when I finished some other pending stuff in this and other projects.)

sbernard31 commented 8 months ago

Thx for sharing that. I totally missed this API.

I tired to use it and it seems it works for my need. (at least is OK with my unit tests)

Not sure, if that has a chance to work on removing the resource itself.

I didn't test that for now.

I think we can close this issue ?

boaks commented 8 months ago

I think we can close this issue ?

At least for v 3.x.y