A resource observer registry.
More...
#include <Observers.h>
|
| Observer & | operator[] (size_t index) |
| | Get the observer at the given index.
|
| |
| const Observer & | operator[] (size_t index) const |
| | Get the observer at the given index.
|
| |
| size_t | length () const |
| | Get the maximum number of observers that can be stored in the registry.
|
| |
| ErrorCode | add (IPAddress ip, uint16_t port, const uint8_t *token, uint8_t tokenLength) |
| | Add a new observer to the registry.
|
| |
| ErrorCode | remove (IPAddress ip, uint16_t port, const uint8_t *token, uint8_t tokenLength) |
| | Remove an observer from the registry.
|
| |
| ErrorCode | remove (const Observer &observer) |
| | Remove an observer from the registry.
|
| |
template<size_t N>
class Coap::ObserverRegistry< N >
A resource observer registry.
It tracks the observers registered to a specific resource.
Example:
myRegistry.
add(ip1, port1, token1, tokenLength1);
A resource observer registry.
Definition Observers.h:163
ErrorCode add(IPAddress ip, uint16_t port, const uint8_t *token, uint8_t tokenLength)
Add a new observer to the registry.
Definition Observers.h:215
A remote CoAP observer, actively observing a resource.
Definition Observers.h:23
- Todo
- Add support to clean up older observers.
◆ add()
Add a new observer to the registry.
If the observer already exists and is active, it will not be added again.
- Parameters
-
| ip | The IP address of the observer. |
| port | The port of the observer. |
| token | The token used by the observer. |
| tokenLength | The length of the token in bytes. |
- Returns
- An error code indicating success or failure. It will return ErrorCode::OK if the observer is successfully added (or was already present). It will return ErrorCode::NOT_SUPPORTED if the registry is full and the observer cannot be added.
◆ length()
Get the maximum number of observers that can be stored in the registry.
- Returns
- The maximum number of entries.
◆ operator[]() [1/2]
Get the observer at the given index.
- Parameters
-
- Returns
- Reference to the observer.
◆ operator[]() [2/2]
Get the observer at the given index.
- Parameters
-
- Returns
- Const reference to the observer.
◆ remove() [1/2]
◆ remove() [2/2]
Remove an observer from the registry.
The observer must match the provided combination of IP address, port, token and token length.
- Parameters
-
| ip | The IP address of the observer that needs to be removed. |
| port | The port of the observer. |
| token | The token used by the observer. |
| tokenLength | The length of the token in bytes. |
- Returns
- An error code indicating success or failure. It will return ErrorCode::OK if the observer is successfully removed. It will return ErrorCode::NOT_FOUND if no matching observer is found
The documentation for this class was generated from the following file: