Skip to content

Add watch/unwatch APIs to Gateways to "subscribe" to Parameter changes #20

Description

@notthetup

UnetStack supports ParameterChangeNtf which is sent by default when an Agent wants to notify others of a change in parameter value. Most UnetStack Agents send these out on the Topic.PARAMCHANGE topic.

Many applications written around UnetStack want to keep a tab on the values of these parameters and want to get notified when these change. A great example of this would be a UI which shows the location of the node. That's captured by the node.location parameter. Having a mechanism to "watch" this parameter would allow easy integration to reactive Web UI frameworks like Vue.js or React.

So I propose we add on new APIs to allow "watching" parameter changes. But there are a few decisions to be made.

  • Where should this API go? UnetSocket object could be a host, but some users of UnetSockets do use a bare fjåge Gateway that's exported by UnetSockets package. Ideally we want this functionality for all.
  • Another approach is to create a new subtype UnetGateway which has this functionality and is used by UnetSocket internally.
  • The actual API may be this :
    • UnetGateway.watch(AgentID agent, String paramName, int index, Function callback) -> handle
    • handle.unwatch()
  • Should we support having a single watcher for all parameters of a single Agent? So something like UnetGateway.watch(AgentID agent, int index, Function callback)? And also all indexes? Is this complexity better in UnetSocket or in the user of UnetSocket?
  • We should also snoop on ALL ParameterRsp and update any values opportunistically.

Thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions