Comments (7)
@chrysn
WDYT maybe it is a good idea to introduce an additional cancel_observation
method on ObservableResource
to notify the resource about observe cancellation? Just to keep it symmetric to the existing add_observation
handler?
from aiocoap.
Removal of observations generally happens via the cancellation callback passed to the ServerObservation's accept method; this allows an observation to be properly cancelled (pending bugs like this one, when cancellation_callback is probably not properly called, haven't looked properly yet), even when for example it has changed its path in the meantime. (Not a situation I'd expect to be common, but possible for kind of dynamic resources.) When add_obsevation is called, eg. on a Site, the ServerObservation is passed around until it gets accepted by a resource object, and I'm in favor of establishing the relationship to that object at accept time instead of hoping that a parallel cancel_observation would find its way to the very object the add_observation found, however likely it is in most cases.
Do you have a suggestion on how to fix this bug that would be made easier if there were a cancel_observation?
from aiocoap.
What i am actually trying to do is to establish a producer for an observation, which is to be notified via cancel_observation (server-side cancellation, not self-triggered) to not produce the notifications anymore (by using asyncio loop, my producer just reschedules itself periodically).
With no expectation of corner cases here i am currently not aware of, i would try a naive approach of looking up the cancel_observation
attribute on a ObservableResource (by convention). If this one is present, it is to be called, i think after calling remove() on the server observation. But as i said, just a naive approach, maybe it makes much more sense to somehow let the resource keep the server observation until a cancellation is needed.
from aiocoap.
You may close the issue, if you think that such a callback is not necessary.
from aiocoap.
I see now what you are aiming for (the resource implementation needs to know when it is being observed, eg. to establish a fnotify); in light of that, my previous answer was not exactly to point.
To give me some leeway in how to implement observations, I try to keep the ServerObservation objects out of the ObservableResource as far as possible; a .cancel_observation
would be possible, but as long as the actual question is "am i being observed", would a .update_observation_count
(called with 0 or non-zero) method work for you?
from aiocoap.
Yes, this is exactly what i am looking for.
from aiocoap.
Thank you 👍
from aiocoap.
Related Issues (20)
- Connection time role reversal for CoAP-over-WS HOT 5
- Get all partial packages received instead of discarding them? HOT 3
- Ignore DTLS Certificate
- Erroneous code in exception path
- CoAP-over-WebSockets stalls on unclean shutdown
- Inform application of transport related events
- 'An error occurred: [WinError 1168] Element not found' after multiple get requests
- udp6: Avoid special handling of unknown local addresses
- gbulb tests fail for short-lived contexts HOT 1
- GET+observe with new state to trigger some process
- DTLS inclusion of server implementation
- coaps+ws: SSL Context defaults to `None` which make websockets connect through HTTP HOT 6
- pyodide: Prune transports
- How to use port 5683 for both client and server to send and receive device messages HOT 2
- Creating URI for the request without coap scheme HOT 2
- Tests don't cover regular UDP behavior
- Token variable in Message seems to get ignored. HOT 4
- Tradfri: Home Assistant: TypeError("'NoneType' object does not support item assignment") HOT 3
- Specifiy the network interface on windows HOT 3
- Adding Type Annotations and Package Type Information HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiocoap.