|
|
|
@ -121,7 +121,7 @@ bc:set("some_noun", 4321)
|
|
|
|
### `BaseControl:get(noun, [timeout])`
|
|
|
|
### `BaseControl:get(noun, [timeout])`
|
|
|
|
Get the value of a noun named `noun`. `get` can not be called for verbs.
|
|
|
|
Get the value of a noun named `noun`. `get` can not be called for verbs.
|
|
|
|
If `timeout` is supplied, the call will return early if no response came before
|
|
|
|
If `timeout` is supplied, the call will return early if no response came before
|
|
|
|
the timeout expired.
|
|
|
|
the timeout expired. `get` will return `nil` if a name is not known.
|
|
|
|
```lua
|
|
|
|
```lua
|
|
|
|
local bc = require("bc"):finalize{"some_noun"}
|
|
|
|
local bc = require("bc"):finalize{"some_noun"}
|
|
|
|
print("Value: ", bc:get("some_noun"))
|
|
|
|
print("Value: ", bc:get("some_noun"))
|
|
|
|
@ -166,7 +166,8 @@ If it is not known at this time, the listener is still installed in hope that
|
|
|
|
the node will come online later. `query` must be a valid query, chosen from
|
|
|
|
the node will come online later. `query` must be a valid query, chosen from
|
|
|
|
`BaseControl.Query`. A full list of currently supported queries was shown above.
|
|
|
|
`BaseControl.Query`. A full list of currently supported queries was shown above.
|
|
|
|
The `callback` function will get one argument: The new value of the noun that
|
|
|
|
The `callback` function will get one argument: The new value of the noun that
|
|
|
|
triggered the event.
|
|
|
|
triggered the event. `listen` returns a unique id for the installed listener
|
|
|
|
|
|
|
|
that could later be used to cancel it.
|
|
|
|
|
|
|
|
|
|
|
|
```lua
|
|
|
|
```lua
|
|
|
|
bc = require("bc"):finalize{"some_noun"}
|
|
|
|
bc = require("bc"):finalize{"some_noun"}
|
|
|
|
@ -178,6 +179,21 @@ bc:listen("some_noun", bc.Query.Below(0), function(value)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### `BaseControl:cancel(id)`
|
|
|
|
|
|
|
|
Cancel a previously installed listener. The id will be invalid after this call.
|
|
|
|
|
|
|
|
```lua
|
|
|
|
|
|
|
|
local listenid = bc:listen("some_noun", bc.Query.Change, function(value)
|
|
|
|
|
|
|
|
print("'some_noun' is now '"..value.."'")
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Later ...
|
|
|
|
|
|
|
|
bc:cancel(listenid)
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### `BaseControl:close()`
|
|
|
|
|
|
|
|
End this base-controller and notify others of the local nouns and verbs going
|
|
|
|
|
|
|
|
offline. Close will also cancel all installed listeners.
|
|
|
|
|
|
|
|
|
|
|
|
Introspection API
|
|
|
|
Introspection API
|
|
|
|
-----------------
|
|
|
|
-----------------
|
|
|
|
The following methods give you insight into the network:
|
|
|
|
The following methods give you insight into the network:
|
|
|
|
@ -192,11 +208,13 @@ Whether `verb` is known at this time (either local or remote). Note that even i
|
|
|
|
a verb is known, calling it might still not succeed if the remote node exited
|
|
|
|
a verb is known, calling it might still not succeed if the remote node exited
|
|
|
|
without deregistering. If you need to know for sure, call using `call_sync`.
|
|
|
|
without deregistering. If you need to know for sure, call using `call_sync`.
|
|
|
|
|
|
|
|
|
|
|
|
### `BaseControl:nouns()`
|
|
|
|
### `BaseControl:nouns([local_only])`
|
|
|
|
Returns a list of all known nouns (either local or remote).
|
|
|
|
Returns a list of all known nouns (either local or remote). If `local_only` is
|
|
|
|
|
|
|
|
boolean true, only a list of local nouns will be returned.
|
|
|
|
|
|
|
|
|
|
|
|
### `BaseControl:verbs()`
|
|
|
|
### `BaseControl:verbs([local_only])`
|
|
|
|
Returns a list of all known verbs (either local or remote).
|
|
|
|
Returns a list of all known verbs (either local or remote). If `local_only` is
|
|
|
|
|
|
|
|
boolean true, only a list of local verbs will be returned.
|
|
|
|
|
|
|
|
|
|
|
|
Network Configuration
|
|
|
|
Network Configuration
|
|
|
|
---------------------
|
|
|
|
---------------------
|
|
|
|
|