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.
|
| |
| size_t | countActive () const |
| | Get the number of active observers currently stored in the registry.
|
| |
| ErrorCode | add (IPAddress ip, uint16_t port, const uint8_t *token, uint8_t tokenLength) |
| | Add a new active observer to the registry.
|
| |
| ErrorCode | add (Observer observer) |
| | 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 (IPAddress ip, uint16_t port) |
| | Remove any observers with the given combination of IP and port.
|
| |
| ErrorCode | remove (IPAddress ip) |
| | Remove any observers with the given IP.
|
| |
| ErrorCode | remove (const Observer &observer) |
| | Remove an observer from the registry.
|
| |
| ErrorCode | removeStale () |
| | Removes all stale observers 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:177
ErrorCode add(IPAddress ip, uint16_t port, const uint8_t *token, uint8_t tokenLength)
Add a new active observer to the registry.
Definition Observers.h:253
A remote CoAP observer.
Definition Observers.h:21
◆ add() [1/2]
Add a new active observer to the registry.
If an active observer with same data already exists, 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. |
- See also
- add(Observer observer) for the version that accepts an Observer object.
- Note
- RFC-7641 section 4.1 specifies that the list of observers is keyed by endpoint and token. Each ObserverRegistry instance will be associated to a specific resource/endpoint, so that there is no need to record the endpoint within the registry. Observers are also keyed by IP address and port to differenciate among multiple clients using the same token. Therefore the combination of IP, port and token fully identifies the observer.
◆ add() [2/2]
Add a new observer to the registry.
If the observer already exists and is active, it will not be added again.
- Parameters
-
| observer | The observer to be added. The observer must be active to be added to the registry. |
- 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.
◆ countActive()
Get the number of active observers currently stored in the registry.
- Returns
- The number of active observers.
◆ 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/4]
◆ remove() [2/4]
◆ remove() [3/4]
◆ remove() [4/4]
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
◆ removeStale()
The documentation for this class was generated from the following file: