An Obervable class that listens for Signal K stream deltas and notifies any observers of value changes. This serves as a base class for code that needs to listen to the stream, with the most common descendant being SKValueListener
More...
#include <sensesp/signalk/signalk_listener.h>
|
| | SKListener (const String &sk_path, int listen_delay, const String &config_path="") |
| |
| virtual | ~SKListener () |
| |
| String & | get_sk_path () |
| |
| int | get_listen_delay () |
| |
| virtual bool | matches (const String &path) const |
| |
| virtual void | parse_value (const JsonObject &json) |
| |
| virtual bool | wants_meta () const |
| |
| virtual void | parse_meta (const std::shared_ptr< const JsonDocument > &meta_doc) |
| |
| | Observable () |
| |
| | Observable (Observable &&other) |
| | Move constructor.
|
| |
| void | notify () |
| |
| int | attach (std::function< void()> observer) |
| | Attach an observer callback.
|
| |
| void | detach (int id) |
| | Remove a previously attached observer by its ID.
|
| |
| | FileSystemSaveable (const String &config_path) |
| |
| virtual bool | load () override |
| | Load and populate the object from a persistent storage.
|
| |
| virtual bool | save () override |
| | Save the object to a persistent storage.
|
| |
| virtual bool | clear () override |
| | Delete the data from a persistent storage.
|
| |
| bool | find_config_file (const String &config_path, String &filename) |
| |
| | Saveable (const String &config_path) |
| |
| virtual bool | refresh () |
| | Refresh the object. This may or may not access the persistent storage but is not expected to overwrite the object's state.
|
| |
| const String & | get_config_path () const |
| |
An Obervable class that listens for Signal K stream deltas and notifies any observers of value changes. This serves as a base class for code that needs to listen to the stream, with the most common descendant being SKValueListener
- See also
- SKValueListener
Definition at line 23 of file signalk_listener.h.
◆ SKListener()
| sensesp::SKListener::SKListener |
( |
const String & |
sk_path, |
|
|
int |
listen_delay, |
|
|
const String & |
config_path = "" |
|
) |
| |
The constructor
- Parameters
-
| sk_path | The Signal K path that identifies this particular subscription to value |
| listen_delay | How often you want the SK Server to send the data you're subscribing to |
| config_path | The optional configuration path that allows an end user to change the configuration of this object. See the Configurable class for more information. |
Definition at line 15 of file signalk_listener.cpp.
◆ ~SKListener()
| sensesp::SKListener::~SKListener |
( |
| ) |
|
|
virtual |
Unregisters this listener from the static registry so the registry never holds a dangling pointer. Takes the listener semaphore because the WS client task iterates the registry under the same lock.
Definition at line 24 of file signalk_listener.cpp.
◆ clear_registry()
| void sensesp::SKListener::clear_registry |
( |
| ) |
|
|
static |
Empties the listener registry. Intended for clean app restart and test isolation; not for normal runtime use. Takes the listener semaphore.
Definition at line 31 of file signalk_listener.cpp.
◆ get_listen_delay()
| int sensesp::SKListener::get_listen_delay |
( |
| ) |
|
|
inline |
◆ get_listeners()
| static const std::vector< SKListener * > & sensesp::SKListener::get_listeners |
( |
| ) |
|
|
inlinestatic |
◆ get_sk_path()
| String & sensesp::SKListener::get_sk_path |
( |
| ) |
|
|
inline |
Returns the current Signal K path. An empty string is returned if this particular source is not configured or intended to return actual data.
Definition at line 50 of file signalk_listener.h.
◆ matches()
| virtual bool sensesp::SKListener::matches |
( |
const String & |
path | ) |
const |
|
inlinevirtual |
Whether a received delta on path should be routed to this listener.
Defaults to an exact match against sk_path. Listeners that observe a family of paths (e.g. a prefix subscription like notifications.*, where the server publishes on paths the client cannot enumerate in advance) override this to widen the match. SKWSClient::process_received_updates calls it per delta instead of comparing paths directly, so the routing policy lives with the listener.
Reimplemented in sensesp::SKPrefixListener.
Definition at line 64 of file signalk_listener.h.
◆ parse_meta()
| virtual void sensesp::SKListener::parse_meta |
( |
const std::shared_ptr< const JsonDocument > & |
meta_doc | ) |
|
|
inlinevirtual |
◆ parse_value()
| virtual void sensesp::SKListener::parse_value |
( |
const JsonObject & |
json | ) |
|
|
inlinevirtual |
◆ release_semaphore()
| void sensesp::SKListener::release_semaphore |
( |
| ) |
|
|
static |
◆ take_semaphore()
| bool sensesp::SKListener::take_semaphore |
( |
uint64_t |
timeout_ms = 0 | ) |
|
|
static |
◆ wants_meta()
| virtual bool sensesp::SKListener::wants_meta |
( |
| ) |
const |
|
inlinevirtual |
◆ sk_path
| String sensesp::SKListener::sk_path {} |
|
protected |
The documentation for this class was generated from the following files: